robotpy / pyfrc

python3 library designed to make developing RobotPy-based code easier!
MIT License
52 stars 35 forks source link

[BUG] Cleanup doesn't occur correctly if tests fail #229

Open virtuald opened 9 months ago

virtuald commented 9 months ago

I think what's happening is that when pytest is processing the exception, the traceback holds references to local objects (including the robot) and so the robot and related objects (in some cases) are never fully freed, so when the hal handles and other things are cleared at the end of the test those objects are all orphaned. Several solutions come to mind:

I believe this is causing https://github.com/robotpy/robotpy-navx/issues/30, but I don't have conclusive proof.

auscompgeek commented 9 months ago

I think what's happening is that when pytest is processing the exception, the traceback holds references to local objects (including the robot) and so the robot and related objects (in some cases) are never fully freed, so when the hal handles and other things are cleared at the end of the test those objects are all orphaned.

I concur here.

We can technically run each tests in a new process now since the CLI doesn't have to import the robot code.

I've used pytest-forked previously, but that doesn't work on Windows.

Maybe it's time to solve #212 and use pytest-xdist?