Skip to content

Commit

Permalink
pytest_plugin: GC after resetting command scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
auscompgeek committed Jul 6, 2024
1 parent bc9ecad commit a29e513
Showing 1 changed file with 5 additions and 7 deletions.
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

0 comments on commit a29e513

Please sign in to comment.