Skip to content

Commit 8facf1d

Browse files
authored
Merge pull request #4457 from nicoddemus/test-request-garbage
Try to fix/improve reporting of test_request_garbage
2 parents 860bc50 + 9e522c9 commit 8facf1d

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

testing/python/fixture.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -526,23 +526,16 @@ def something(request):
526526
527527
try:
528528
gc.collect()
529-
leaked_types = sum(1 for _ in gc.garbage
530-
if isinstance(_, PseudoFixtureDef))
531-
532-
# debug leaked types if the test fails
533-
print(leaked_types)
534-
535-
gc.garbage[:] = []
536-
537-
assert leaked_types == 0
529+
leaked = [x for _ in gc.garbage if isinstance(_, PseudoFixtureDef)]
530+
assert leaked == []
538531
finally:
539532
gc.set_debug(original)
540533
541534
def test_func():
542535
pass
543536
"""
544537
)
545-
result = testdir.runpytest()
538+
result = testdir.runpytest_subprocess()
546539
result.stdout.fnmatch_lines("* 1 passed in *")
547540

548541
def test_getfixturevalue_recursive(self, testdir):

0 commit comments

Comments
 (0)