Skip to content

Regression in 3.7.0: AttributeError for _collectfile #3742

Closed

Description

@fschulze

I get AttributeError: 'FlakesItem' object has no attribute '_collectfile' when running devpi-server tests with tox (tox -e py27 is enough) since pytest 3.7.0. When I pin to pytest<3.7dev it works (using 3.6.4).

It seems to be related to the current working directory. The tox config switches to test_devpi_server. When I run pytest in server it's fine, when i run in server/test_devpi_server it breaks.

Activity

  1. The-Compiler commented on Jul 31, 2018

    @The-Compiler
    Member

    Not sure if this is an issue in pytest itself, or the pytest-flakes plugin.

  2. pytestbot commented on Jul 31, 2018

    @pytestbot
    Contributor

    GitMate.io thinks possibly related issues are #707 (pytest-xdist regression since execnet 1.3.0), #2968 (Memory usage in 3.3.0), #1083 (Regression with parallel tests on 2.7.3 and 2.8), #386 (tests fail with pexpect-3.0), and #1572 (Making _CallOutcome.result private in 3.0).

  3. RonnyPfannschmidt commented on Jul 31, 2018

    @RonnyPfannschmidt
    Member

    this is a regression made by pytest - root._collectfile got introduced in #3389

    this triggered a unintentional regression as now a private api is used in more places and on objects that dont belong to it

  4. added
    type: regressionindicates a problem that was introduced in a release which was working previously
    on Jul 31, 2018
  5. JohanLorenzo commented on Jul 31, 2018

    @JohanLorenzo

    Hello! Thank you for this great library! The Mozilla release engineering team relies on it for several projects 😃

    I just found a similar regression:

    AttributeError: 'async_generator' object has no attribute 'put'

    This async generator is a regular aiohttp.ClientSession() and is initialized here. This might be an integration issue with the pytest-asyncio plugin.

    I rolled pytest back to 3.6.4 and things are back working. You can see both the failure and the workaround in

  6. RonnyPfannschmidt commented on Jul 31, 2018

    @RonnyPfannschmidt
    Member

    @JohanLorenzo this is a different issue - related to fixture definitions, please open a new issue

  7. JohanLorenzo commented on Jul 31, 2018

    @JohanLorenzo

    Thanks for the quick answer. I opened #3747

  8. Thomasillo commented on Jul 31, 2018

    @Thomasillo

    Same here with flake8:

    $ py.test --flake8 package
    =========================================================================================== test session starts ============================================================================================
    platform darwin -- Python 3.6.2, pytest-3.7.0, py-1.5.3, pluggy-0.7.1
    rootdir: /Users/Thomas/Work/stuff, inifile: setup.cfg
    plugins: flake8-1.0.1, cov-2.5.1, hypothesis-3.57.0
    collected 0 items / 1 errors                                                                                                                                                                               
    
    ================================================================================================== ERRORS ==================================================================================================
    ____________________________________________________________________________________________ ERROR collecting  _____________________________________________________________________________________________
    ../../../../.local/miniconda3/envs/test/lib/python3.6/site-packages/_pytest/runner.py:201: in __init__
        self.result = func()
    ../../../../.local/miniconda3/envs/test/lib/python3.6/site-packages/_pytest/runner.py:261: in <lambda>
        call = CallInfo(lambda: list(collector.collect()), "collect")
    ../../../../.local/miniconda3/envs/test/lib/python3.6/site-packages/_pytest/main.py:475: in collect
        for x in self._collect(arg):
    ../../../../.local/miniconda3/envs/test/lib/python3.6/site-packages/_pytest/main.py:519: in _collect
        for x in root._collectfile(pkginit):
    E   AttributeError: 'Flake8Item' object has no attribute '_collectfile'
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ========================================================================================= 1 error in 0.17 seconds ==========================================================================================
  9. ThreePinkApples commented on Jul 31, 2018

    @ThreePinkApples

    Getting the same with PEP8

    ============================= test session starts ==============================
    platform linux -- Python 3.6.4, pytest-3.7.0, py-1.5.4, pluggy-0.7.1
    rootdir: /var/lib/jenkins/jobs/Simplereg/workspace, inifile:
    plugins: xdist-1.22.5, twisted-1.8, pep8-1.0.6, forked-0.2, cov-2.5.1
    collected 0 items / 1 errors
    
    ==================================== ERRORS ====================================
    ______________________________ ERROR collecting  _______________________________
    .tox/py36/lib/python3.6/site-packages/_pytest/runner.py:201: in __init__
        self.result = func()
    .tox/py36/lib/python3.6/site-packages/_pytest/runner.py:261: in <lambda>
        call = CallInfo(lambda: list(collector.collect()), "collect")
    .tox/py36/lib/python3.6/site-packages/_pytest/main.py:475: in collect
        for x in self._collect(arg):
    .tox/py36/lib/python3.6/site-packages/_pytest/main.py:519: in _collect
        for x in root._collectfile(pkginit):
    E   AttributeError: 'Pep8Item' object has no attribute '_collectfile
    
  10. cdeil commented on Jul 31, 2018

    @cdeil

    We're seeing this error after the update pytest 3.6 -> 3.7:

    __________________________ ERROR collecting  _______________________________
    �[1m�[31m/home/travis/miniconda/envs/test/lib/python2.7/site-packages/_pytest/runner.py�[0m:201: in __init__
    �[1m    self.result = func()�[0m
    �[1m�[31m/home/travis/miniconda/envs/test/lib/python2.7/site-packages/_pytest/runner.py�[0m:261: in <lambda>
    �[1m    call = CallInfo(lambda: list(collector.collect()), "collect")�[0m
    �[1m�[31m/home/travis/miniconda/envs/test/lib/python2.7/site-packages/_pytest/main.py�[0m:475: in collect
    �[1m    for x in self._collect(arg):�[0m
    �[1m�[31m/home/travis/miniconda/envs/test/lib/python2.7/site-packages/_pytest/main.py�[0m:519: in _collect
    �[1m    for x in root._collectfile(pkginit):�[0m
    �[1m�[31mE   AttributeError: 'Pair' object has no attribute '_collectfile'�[0m
    !!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
    

    https://travis-ci.org/gammapy/gammapy/jobs/410288389#L2253

    Same issue or a different one?

  11. RonnyPfannschmidt commented on Jul 31, 2018

    @RonnyPfannschmidt
    Member

    same all issues that are triggered by _collectfile missing on 3rd party items are due to this one
    its an entirely unintended issue

  12. changed the title [-]Regression in 3.7.0[/-] [+]Regression in 3.7.0: AttributeError for _collectfile[/+] on Jul 31, 2018
  13. castarco commented on Jul 31, 2018

    @castarco

    In our team we're suffering the same problem, we had to fix the pytest version to 3.6.4 to avoid this regression.

  14. 4 remaining items

  15. RonnyPfannschmidt commented on Aug 1, 2018

    @RonnyPfannschmidt
    Member

    as far as i can tell the code paths considering the change of root are incorrect, falling back to self is only hiding the issue

  16. henry0312 commented on Aug 1, 2018

    @henry0312

    I don't understand why __collectfile with the last root is called.

  17. added a commit that references this issue on Aug 1, 2018
  18. added a commit that references this issue on Aug 2, 2018
  19. added a commit that references this issue on Aug 2, 2018
  20. added a commit that references this issue on Aug 3, 2018
  21. added a commit that references this issue on Aug 3, 2018
  22. added a commit that references this issue on Aug 10, 2018
  23. added a commit that references this issue on Aug 14, 2018
  24. darland commented on Aug 15, 2018

    @darland

    I got the same error if I run tests like this pytest tests/unit/*.py

    E   AttributeError: 'list' object has no attribute '_collectfile'
    

    But if I run like this pytest tests/unit/, it passes.

  25. added a commit that references this issue on Aug 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: criticalgrave problem or usability issue that affects lots of userstype: bugproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previously

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions