Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky test: test_request_garbage #4346

Closed
blueyed opened this issue Nov 8, 2018 · 1 comment
Closed

Flaky test: test_request_garbage #4346

blueyed opened this issue Nov 8, 2018 · 1 comment
Labels
type: bug problem that needs to be addressed type: infrastructure improvement to development/releases/CI structure

Comments

@blueyed
Copy link
Contributor

blueyed commented Nov 8, 2018

It was marked to be skipped with xdist in 4808145 (#4144 (comment)). The failure mentioned there (#4144 (comment)) appears to be different from the one below though.

assert leaked_types == 0

https://travis-ci.org/pytest-dev/pytest/jobs/451681349#L997

=================================== FAILURES ===================================
____________________ TestRequestBasic.test_request_garbage _____________________
self = <fixture.TestRequestBasic object at 0x7f2f9b626080>
testdir = <Testdir local('/tmp/pytest-of-travis/pytest-0/test_request_garbage0')>
    @pytest.mark.skipif(
        hasattr(sys, "pypy_version_info"),
        reason="this method of test doesn't work on pypy",
    )
    def test_request_garbage(self, testdir):
        try:
            import xdist  # noqa
        except ImportError:
            pass
        else:
            pytest.xfail("this test is flaky when executed with xdist")
        testdir.makepyfile(
            """
            import sys
            import pytest
            from _pytest.fixtures import PseudoFixtureDef
            import gc
    
            @pytest.fixture(autouse=True)
            def something(request):
                original = gc.get_debug()
                gc.set_debug(gc.DEBUG_SAVEALL)
                gc.collect()
    
                yield
    
                try:
                    gc.collect()
                    leaked_types = sum(1 for _ in gc.garbage
                                       if isinstance(_, PseudoFixtureDef))
    
                    # debug leaked types if the test fails
                    print(leaked_types)
    
                    gc.garbage[:] = []
    
                    assert leaked_types == 0
                finally:
                    gc.set_debug(original)
    
            def test_func():
                pass
        """
        )
        result = testdir.runpytest()
>       result.stdout.fnmatch_lines("* 1 passed in *")
E       Failed: nomatch: '* 1 passed in *'
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.7.1, pytest-3.10.1.dev17+g176d274, py-1.7.0, pluggy-0.8.0'
E           and: "hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/travis/build/pytest-dev/pytest/.hypothesis/examples')"
E           and: 'rootdir: /tmp/pytest-of-travis/pytest-0/test_request_garbage0, inifile:'
E           and: 'plugins: hypothesis-3.82.1'
E           and: 'collected 1 item'
E           and: ''
E           and: 'test_request_garbage.py .E                                               [100%]'
E           and: ''
E           and: '==================================== ERRORS ===================================='
E           and: '________________________ ERROR at teardown of test_func ________________________'
E           and: ''
E           and: "request = <SubRequest 'something' for <Function 'test_func'>>"
E           and: ''
E           and: '    @pytest.fixture(autouse=True)'
E           and: '    def something(request):'
E           and: '        original = gc.get_debug()'
E           and: '        gc.set_debug(gc.DEBUG_SAVEALL)'
E           and: '        gc.collect()'
E           and: '    '
E           and: '        yield'
E           and: '    '
E           and: '        try:'
E           and: '            gc.collect()'
E           and: '            leaked_types = sum(1 for _ in gc.garbage'
E           and: '                               if isinstance(_, PseudoFixtureDef))'
E           and: '    '
E           and: '            # debug leaked types if the test fails'
E           and: '            print(leaked_types)'
E           and: '    '
E           and: '            gc.garbage[:] = []'
E           and: '    '
E           and: '>           assert leaked_types == 0'
E           and: 'E           assert 4 == 0'
E           and: ''
E           and: 'test_request_garbage.py:24: AssertionError'
E           and: '--------------------------- Captured stdout teardown ---------------------------'
E           and: '4'
E           and: '====================== 1 passed, 1 error in 0.62 seconds ======================='
E           and: ''
E       remains unmatched: '* 1 passed in *'
/home/travis/build/pytest-dev/pytest/testing/python/fixture.py:545: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.7.1, pytest-3.10.1.dev17+g176d274, py-1.7.0, pluggy-0.8.0
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/travis/build/pytest-dev/pytest/.hypothesis/examples')
rootdir: /tmp/pytest-of-travis/pytest-0/test_request_garbage0, inifile:
plugins: hypothesis-3.82.1
collected 1 item
test_request_garbage.py .E                                               [100%]
==================================== ERRORS ====================================
________________________ ERROR at teardown of test_func ________________________
request = <SubRequest 'something' for <Function 'test_func'>>
    @pytest.fixture(autouse=True)
    def something(request):
        original = gc.get_debug()
        gc.set_debug(gc.DEBUG_SAVEALL)
        gc.collect()
    
        yield
    
        try:
            gc.collect()
            leaked_types = sum(1 for _ in gc.garbage
                               if isinstance(_, PseudoFixtureDef))
    
            # debug leaked types if the test fails
            print(leaked_types)
    
            gc.garbage[:] = []
    
>           assert leaked_types == 0
E           assert 4 == 0
test_request_garbage.py:24: AssertionError
--------------------------- Captured stdout teardown ---------------------------
4
====================== 1 passed, 1 error in 0.62 seconds =======================
=========================== short test summary info ============================
FAIL testing/python/fixture.py::TestRequestBasic::()::test_request_garbage
@blueyed blueyed added type: bug problem that needs to be addressed type: infrastructure improvement to development/releases/CI structure labels Nov 8, 2018
@blueyed
Copy link
Contributor Author

blueyed commented Nov 24, 2018

Hopefully resolved through #4457 - otherwise let's reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed type: infrastructure improvement to development/releases/CI structure
Projects
None yet
Development

No branches or pull requests

1 participant