Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest_plugin: GC after resetting command scheduler #233

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions pyfrc/test_support/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ def robot(self):

del robot

# Double-check all objects are destroyed so that HAL handles are released
gc.collect()

if commands2 is not None:
commands2.CommandScheduler.resetInstance()

# Double-check all objects are destroyed so that HAL handles are released
gc.collect()

# shutdown networktables before other kinds of global cleanup
# -> some reset functions will re-register listeners, so it's important
# to do this before so that the listeners are active on the current
Expand Down Expand Up @@ -146,13 +146,11 @@ def robot(self):
# hal.shutdown()

@pytest.fixture(scope="function")
def control(self, reraise, robot) -> TestController:
def control(self, reraise, robot: wpilib.RobotBase) -> TestController:
"""
A pytest fixture that provides control over your robot
"""
controller = TestController(reraise, robot)
yield controller
del controller
return TestController(reraise, robot)

@pytest.fixture()
def robot_file(self) -> pathlib.Path:
Expand Down
Loading