tholo / pytest-flake8

pytest plugin to run flake8
Other
117 stars 47 forks source link

Fails with pytest 3.7.0: AttributeError: 'Flake8Item' object has no attribute '_collectfile' #51

Closed khink closed 6 years ago

khink commented 6 years ago

I'm not entirely sure the issue is with pytest-flake8, but i'll report here first and wait for response.

Our tests started failing yesterday after the release of https://pypi.org/project/pytest/3.7.0/. The error was:

Installing collected packages: Willow, djangorestframework, six, pytz, l18n, chardet, idna, urllib3, certifi, requests, Unidecode, Django, django-modelcluster, django-treebeard, draftjs-exporter, webencodings, html5lib, django-taggit, Pillow, beautifulsoup4, wagtail, psycopg2, pyflakes, pycodestyle, mccabe, flake8, more-itertools, atomicwrites, attrs, pluggy, pathlib2, py, pytest, pytest-flake8, sqlparse, django-debug-toolbar, pep8, asn1crypto, pycparser, cffi, cryptography, pynacl, bcrypt, pyasn1, paramiko, Fabric3
Successfully installed Django-2.0.7 Fabric3-1.14.post1 Pillow-5.2.0 Unidecode-0.4.21 Willow-1.1 asn1crypto-0.24.0 atomicwrites-1.1.5 attrs-18.1.0 bcrypt-3.1.4 beautifulsoup4-4.6.1 certifi-2018.4.16 cffi-1.11.5 chardet-3.0.4 cryptography-2.3 django-debug-toolbar-1.9.1 django-modelcluster-4.1 django-taggit-0.22.2 django-treebeard-4.3 djangorestframework-3.8.2 draftjs-exporter-2.1.2 flake8-3.5.0 html5lib-1.0.1 idna-2.7 l18n-2016.6.4 mccabe-0.6.1 more-itertools-4.2.0 paramiko-2.4.1 pathlib2-2.3.2 pep8-1.7.1 pluggy-0.7.1 psycopg2-2.7.5 py-1.5.4 pyasn1-0.4.4 pycodestyle-2.3.1 pycparser-2.18 pyflakes-1.6.0 pynacl-1.2.1 pytest-3.7.0 pytest-flake8-1.0.2 pytz-2018.5 requests-2.19.1 six-1.11.0 sqlparse-0.2.4 urllib3-1.23 wagtail-2.1.1 webencodings-0.5.1
touch requirements.txt.done
env/bin/pytest --flake8 
============================= test session starts ==============================
platform linux -- Python 3.5.2, pytest-3.7.0, py-1.5.4, pluggy-0.7.1
...
plugins: flake8-1.0.2
collected 0 items / 1 errors

==================================== ERRORS ====================================
______________________________ ERROR collecting  _______________________________
env/lib/python3.5/site-packages/_pytest/runner.py:201: in __init__
    self.result = func()
env/lib/python3.5/site-packages/_pytest/runner.py:261: in <lambda>
    call = CallInfo(lambda: list(collector.collect()), "collect")
env/lib/python3.5/site-packages/_pytest/main.py:475: in collect
    for x in self._collect(arg):
env/lib/python3.5/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 ============================
Makefile:24: recipe for target 'test' failed

After downgrading pytest to 3.6.4 the tests passed.

sallner commented 6 years ago

This is related to https://github.com/pytest-dev/pytest/issues/3742 an it seems like it should be fixed in pytest. Best solution is to downgrade to 3.6.4 till the next bugfix release. .

khink commented 6 years ago

Thanks!