Skip to content

Commit

Permalink
Merge pull request #233 from robotpy/gc-after-reset-sched
Browse files Browse the repository at this point in the history
pytest_plugin: GC after resetting command scheduler
  • Loading branch information
virtuald authored Jul 7, 2024
2 parents bc9ecad + a29e513 commit 30ac771
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 30ac771

Please sign in to comment.