File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -519,6 +519,41 @@ def test_method(self, something):
519
519
assert len (arg2fixturedefs ) == 1
520
520
assert arg2fixturedefs ['something' ][0 ].argname == "something"
521
521
522
+ def test_request_garbage (self , testdir ):
523
+ testdir .makepyfile ("""
524
+ import sys
525
+ import pytest
526
+ import gc
527
+
528
+ @pytest.fixture(autouse=True)
529
+ def something(request):
530
+ # this method of test doesn't work on pypy
531
+ if hasattr(sys, "pypy_version_info"):
532
+ yield
533
+ else:
534
+ original = gc.get_debug()
535
+ gc.set_debug(gc.DEBUG_SAVEALL)
536
+ gc.collect()
537
+
538
+ yield
539
+
540
+ gc.collect()
541
+ leaked_types = sum(1 for _ in gc.garbage
542
+ if 'PseudoFixtureDef' in str(_))
543
+
544
+ gc.garbage[:] = []
545
+
546
+ try:
547
+ assert leaked_types == 0
548
+ finally:
549
+ gc.set_debug(original)
550
+
551
+ def test_func():
552
+ pass
553
+ """ )
554
+ reprec = testdir .inline_run ()
555
+ reprec .assertoutcome (passed = 1 )
556
+
522
557
def test_getfixturevalue_recursive (self , testdir ):
523
558
testdir .makeconftest ("""
524
559
import pytest
You can’t perform that action at this time.
0 commit comments