Skip to content

Commit

Permalink
Ensure __main__ module path is absolute
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Dec 22, 2023
1 parent 5b66b23 commit bdf14b5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pyfrc/mains/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def _run_test(self, pytest_args, robot_class, use_builtin, **static_options):
self.robot_class = robot_class
robot_file = pathlib.Path(inspect.getfile(robot_class)).absolute()

# In some cases __main__.__file__ is not an absolute path, and some
# internals depend on that being correct. Set it up before we change
# directories
sys.modules["__main__"].__file__ = abspath(sys.modules["__main__"].__file__)

if robot_file.name == "cProfile.py":
# so, the module for the robot class is __main__, and __main__ is
# cProfile so try to find it
Expand Down

0 comments on commit bdf14b5

Please sign in to comment.