diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2018-04-12 07:53:34 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-12 07:53:34 -0300 |
commit | 015626ce69bfda6e12aad4e3c4454cf35ff5ac95 (patch) | |
tree | cedbf193b9bac8f62129fcf9c253a4c18537e150 /testing/acceptance_test.py | |
parent | f9a908abb80747e546a1fa87ce30d379257f38ce (diff) | |
parent | 6e8e3c967ada43ba47d0b85842607a5f975c5c81 (diff) | |
download | pytest-015626ce69bfda6e12aad4e3c4454cf35ff5ac95.tar.gz |
Merge pull request #3384 from nicoddemus/leak-frame
Reset reference to failed test frame before each test executes
Diffstat (limited to 'testing/acceptance_test.py')
-rw-r--r-- | testing/acceptance_test.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/testing/acceptance_test.py b/testing/acceptance_test.py index 89a44911f..8ceb3bae1 100644 --- a/testing/acceptance_test.py +++ b/testing/acceptance_test.py @@ -988,3 +988,33 @@ def test_fixture_order_respects_scope(testdir): ''') result = testdir.runpytest() assert result.ret == 0 + + +def test_frame_leak_on_failing_test(testdir): + """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 + can be eventually claimed by the garbage collector. + """ + testdir.makepyfile(''' + import gc + import weakref + + class Obj: + pass + + ref = None + + def test1(): + obj = Obj() + global ref + ref = weakref.ref(obj) + assert 0 + + def test2(): + gc.collect() + assert ref() is None + ''') + result = testdir.runpytest_subprocess() + result.stdout.fnmatch_lines(['*1 failed, 1 passed in*']) |