Try to fix/improve reporting of test_request_garbage

* Run it in a subprocess to reduce possible intereference from the outer pytest
* Print the leaked objects to see if they provide any hints
This commit is contained in:
Bruno Oliveira 2018-11-24 08:29:39 -02:00
parent 860bc50772
commit 9e522c97fa
1 changed files with 3 additions and 10 deletions

View File

@ -526,15 +526,8 @@ class TestRequestBasic(object):
try: try:
gc.collect() gc.collect()
leaked_types = sum(1 for _ in gc.garbage leaked = [x for _ in gc.garbage if isinstance(_, PseudoFixtureDef)]
if isinstance(_, PseudoFixtureDef)) assert leaked == []
# debug leaked types if the test fails
print(leaked_types)
gc.garbage[:] = []
assert leaked_types == 0
finally: finally:
gc.set_debug(original) gc.set_debug(original)
@ -542,7 +535,7 @@ class TestRequestBasic(object):
pass pass
""" """
) )
result = testdir.runpytest() result = testdir.runpytest_subprocess()
result.stdout.fnmatch_lines("* 1 passed in *") result.stdout.fnmatch_lines("* 1 passed in *")
def test_getfixturevalue_recursive(self, testdir): def test_getfixturevalue_recursive(self, testdir):