Skip to content

TestRequestBasic.test_request_garbage sometimes fails on AppVeyor #3564

@nicoddemus

Description

@nicoddemus

Usually in py27-xdist or py36-xdist on AppVeyor:

================================== FAILURES ===================================
____________________ TestRequestBasic.test_request_garbage ____________________
[gw1] win32 -- Python 2.7.15 c:\projects\pytest\.tox\py27-xdist\scripts\python.exe
self = <fixture.TestRequestBasic object at 0x056F0E90>
testdir = <Testdir local('c:\\users\\appveyor\\appdata\\local\\temp\\1\\pytest-of-appveyor\\pytest-0\\popen-gw1\\test_request_garbage0')>
    def test_request_garbage(self, testdir):
        testdir.makepyfile(
            """
                import sys
                import pytest
                from _pytest.compat import safe_str
                import gc
    
                @pytest.fixture(autouse=True)
                def something(request):
                    # this method of test doesn't work on pypy
                    if hasattr(sys, "pypy_version_info"):
                        yield
                    else:
                        original = gc.get_debug()
                        gc.set_debug(gc.DEBUG_SAVEALL)
                        gc.collect()
    
                        yield
    
                        gc.collect()
                        leaked_types = sum(1 for _ in gc.garbage
                                           if 'PseudoFixtureDef' in safe_str(_))
    
                        gc.garbage[:] = []
    
                        try:
                            assert leaked_types == 0
                        finally:
                            gc.set_debug(original)
    
                def test_func():
                    pass
            """
        )
        reprec = testdir.inline_run()
>       reprec.assertoutcome(passed=1)
C:\projects\pytest\testing\python\fixture.py:664: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.pytester.HookRecorder object at 0x055A6070>, passed = 1
skipped = 0, failed = 0
    def assertoutcome(self, passed=0, skipped=0, failed=0):
        realpassed, realskipped, realfailed = self.listoutcomes()
        assert passed == len(realpassed)
        assert skipped == len(realskipped)
>       assert failed == len(realfailed)
E       AssertionError: assert 0 == 1
E        +  where 1 = len([<TestReport 'test_request_garbage.py::test_func' when='teardown' outcome='failed'>])
c:\projects\pytest\.tox\py27-xdist\lib\site-packages\_pytest\pytester.py:351: AssertionError
---------------------------- Captured stdout call -----------------------------
============================= test session starts =============================
platform win32 -- Python 2.7.15, pytest-3.6.2.dev21+g9ccc38c6, py-1.5.3, pluggy-0.6.0
rootdir: c:\users\appveyor\appdata\local\temp\1\pytest-of-appveyor\pytest-0\popen-gw1\test_request_garbage0, inifile:
plugins: xdist-1.22.2, forked-0.2, hypothesis-3.57.0
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):
        # this method of test doesn't work on pypy
        if hasattr(sys, "pypy_version_info"):
            yield
        else:
            original = gc.get_debug()
            gc.set_debug(gc.DEBUG_SAVEALL)
            gc.collect()
    
            yield
    
            gc.collect()
>           leaked_types = sum(1 for _ in gc.garbage
                               if 'PseudoFixtureDef' in safe_str(_))
test_request_garbage.py:19: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_request_garbage.py:20: in <genexpr>
    if 'PseudoFixtureDef' in safe_str(_))
c:\projects\pytest\.tox\py27-xdist\lib\site-packages\_pytest\compat.py:306: in safe_str
    return str(v)
c:\projects\pytest\.tox\py27-xdist\lib\site-packages\_pytest\_code\code.py:475: in __str__
    entry = self.traceback[-1]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [], key = -1
    def __getitem__(self, key):
>       val = super(Traceback, self).__getitem__(key)
E       IndexError: list index out of range
c:\projects\pytest\.tox\py27-xdist\lib\site-packages\_pytest\_code\code.py:320: IndexError
====================== 1 passed, 1 error in 1.23 seconds ======================

https://ci.appveyor.com/project/pytestbot/pytest/build/1.0.4478/job/1fgioixlgmhc6782

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: infrastructureimprovement to development/releases/CI structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions