Skip to content

TestRequestBasic.test_request_garbage sometimes fails on AppVeyor #3564

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

Closed
nicoddemus opened this issue Jun 10, 2018 · 1 comment · Fixed by #3565
Closed

TestRequestBasic.test_request_garbage sometimes fails on AppVeyor #3564

nicoddemus opened this issue Jun 10, 2018 · 1 comment · Fixed by #3565
Labels
type: infrastructure improvement to development/releases/CI structure

Comments

@nicoddemus
Copy link
Member

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

@nicoddemus nicoddemus added the type: infrastructure improvement to development/releases/CI structure label Jun 10, 2018
@pytestbot
Copy link
Contributor

GitMate.io thinks possibly related issues are #1164 (test_something fails), #74 (test_cmdline_python_package() fails), #1690 (Appveyor is broken), #1163 (TestLoggingInteraction.test_logging_initialized_in_test fails), and #747 (flakes test fail).

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

Successfully merging a pull request may close this issue.

2 participants