From a29e5139548671472d8747d74b15e38595addf3f Mon Sep 17 00:00:00 2001 From: David Vo Date: Sat, 6 Jul 2024 14:48:14 +1000 Subject: [PATCH] pytest_plugin: GC after resetting command scheduler --- pyfrc/test_support/pytest_plugin.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pyfrc/test_support/pytest_plugin.py b/pyfrc/test_support/pytest_plugin.py index 0724319..1aaf81f 100644 --- a/pyfrc/test_support/pytest_plugin.py +++ b/pyfrc/test_support/pytest_plugin.py @@ -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 @@ -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: