Skip to content

Commit bdf14b5

Browse files
committed
Ensure __main__ module path is absolute
- Fixes robotpy/mostrobotpy#31
1 parent 5b66b23 commit bdf14b5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pyfrc/mains/cli_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ def _run_test(self, pytest_args, robot_class, use_builtin, **static_options):
7474
self.robot_class = robot_class
7575
robot_file = pathlib.Path(inspect.getfile(robot_class)).absolute()
7676

77+
# In some cases __main__.__file__ is not an absolute path, and some
78+
# internals depend on that being correct. Set it up before we change
79+
# directories
80+
sys.modules["__main__"].__file__ = abspath(sys.modules["__main__"].__file__)
81+
7782
if robot_file.name == "cProfile.py":
7883
# so, the module for the robot class is __main__, and __main__ is
7984
# cProfile so try to find it

0 commit comments

Comments
 (0)