Pytest would leak garbage referencing the frames of tests that failed that could never be reclaimed (#2798). Unfortunately it was not possible to remove the actual circles because most of them are made of traceback objects which cannot be weakly referenced. Those objects at least ca
(pytester: Pytester)
| 1212 | |
| 1213 | |
| 1214 | def test_frame_leak_on_failing_test(pytester: Pytester) -> None: |
| 1215 | """Pytest would leak garbage referencing the frames of tests that failed |
| 1216 | that could never be reclaimed (#2798). |
| 1217 | |
| 1218 | Unfortunately it was not possible to remove the actual circles because most of them |
| 1219 | are made of traceback objects which cannot be weakly referenced. Those objects at least |
| 1220 | can be eventually claimed by the garbage collector. |
| 1221 | """ |
| 1222 | pytester.makepyfile( |
| 1223 | """ |
| 1224 | import gc |
| 1225 | import weakref |
| 1226 | |
| 1227 | class Obj: |
| 1228 | pass |
| 1229 | |
| 1230 | ref = None |
| 1231 | |
| 1232 | def test1(): |
| 1233 | obj = Obj() |
| 1234 | global ref |
| 1235 | ref = weakref.ref(obj) |
| 1236 | assert 0 |
| 1237 | |
| 1238 | def test2(): |
| 1239 | gc.collect() |
| 1240 | assert ref() is None |
| 1241 | """ |
| 1242 | ) |
| 1243 | result = pytester.runpytest_subprocess() |
| 1244 | result.stdout.fnmatch_lines(["*1 failed, 1 passed in*"]) |
| 1245 | |
| 1246 | |
| 1247 | def test_fixture_mock_integration(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…