tholo / pytest-flake8

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

Breaks with flake8==3.5.0 #34

Closed romanlevin closed 6 years ago

romanlevin commented 6 years ago

Getting failures like this when using flake8==3.5.0:

=================================== FAILURES ===================================
_________________________________ FLAKE8-check _________________________________
.tox/py36/lib/python3.6/site-packages/pytest_flake8.py:115: in runtest
    self.statistics)
.tox/py36/lib/python3.6/site-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
.tox/py36/lib/python3.6/site-packages/pytest_flake8.py:180: in check_file
    app.find_plugins()
.tox/py36/lib/python3.6/site-packages/flake8/main/application.py:176: in find_plugins
    self.prelim_opts.config,
E   AttributeError: 'NoneType' object has no attribute 'config'

test_flake8.py also fails now:

$ tox -e py27
GLOB sdist-make: /Users/romanlevin/workspace/pytest-flake8/setup.py
py27 inst-nodeps: /Users/romanlevin/workspace/pytest-flake8/.tox/dist/pytest-flake8-0.8.1.zip
py27 installed: configparser==3.5.0,enum34==1.1.6,flake8==3.5.0,mccabe==0.6.1,py==1.4.34,pycodestyle==2.3.1,pyflakes==1.6.0,pytest==3.2.3,pytest-flake8==0.8.1
py27 runtests: PYTHONHASHSEED='3487679041'
py27 runtests: commands[0] | py.test --junitxml=/Users/romanlevin/workspace/pytest-flake8/.tox/py27/log/junit-py27.xml
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /Users/romanlevin/workspace/pytest-flake8, inifile: tox.ini
plugins: flake8-0.8.1
collected 13 items

pytest_flake8.py s
setup.py s
test_flake8.py s..FFF.FF.F

-------------------------------------------------------- generated xml file: /Users/romanlevin/workspace/pytest-flake8/.tox/py27/log/junit-py27.xml --------------------------------------------------------
================================================================================================= FAILURES =================================================================================================
_______________________________________________________________________________________ TestIgnores.test_ignores_all _______________________________________________________________________________________

self = <test_flake8.TestIgnores instance at 0x10b489f38>, testdir = <Testdir local('/private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_ignores_all0')>

    def test_ignores_all(self, testdir):
        """Verify success when all errors are ignored."""
        testdir.makeini("""
                [pytest]
                flake8-ignore = E203
                    *.py E300
                    tests/*.py ALL E203 # something
            """)
        testdir.tmpdir.ensure("xy.py")
        testdir.tmpdir.ensure("tests/hello.py")
        result = testdir.runpytest("--flake8", "-s")
>       assert result.ret == 0
E       assert 1 == 0
E        +  where 1 = <_pytest.pytester.RunResult instance at 0x10b4fdef0>.ret

/Users/romanlevin/workspace/pytest-flake8/test_flake8.py:49: AssertionError
------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_ignores_all0, inifile: tox.ini
plugins: flake8-0.8.1
collected 1 item

xy.py F

=================================== FAILURES ===================================
_______________________ FLAKE8-check(ignoring E203 E300) _______________________
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest
    self.statistics)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file
    app.find_plugins()
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins
    self.prelim_opts.config,
E   AttributeError: 'NoneType' object has no attribute 'config'
=========================== 1 failed in 0.09 seconds ===========================
________________________________________________________________________________________ TestIgnores.test_w293w292 _________________________________________________________________________________________

self = <test_flake8.TestIgnores instance at 0x10b4706c8>, testdir = <Testdir local('/private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_w293w2920')>
example = local('/private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_w293w2920/test_w293w292.py')

    def test_w293w292(self, testdir, example):
        result = testdir.runpytest("--flake8", )
        result.stdout.fnmatch_lines([
            # "*plugins*flake8*",
            "*W293*",
>           "*W292*",
        ])
E       Failed: nomatch: '*W293*'
E           and: u'============================= test session starts =============================='
E           and: u'platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0'
E           and: u'rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_w293w2920, inifile:'
E           and: u'plugins: flake8-0.8.1'
E           and: u'collected 1 item'
E           and: u''
E           and: u'test_w293w292.py F'
E           and: u''
E           and: u'=================================== FAILURES ==================================='
E           and: u'_________________________________ FLAKE8-check _________________________________'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest'
E           and: u'    self.statistics)'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call'
E           and: u'    res = func(*args, **kwargs)'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file'
E           and: u'    app.find_plugins()'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins'
E           and: u'    self.prelim_opts.config,'
E           and: u"E   AttributeError: 'NoneType' object has no attribute 'config'"
E           and: u'=========================== 1 failed in 0.05 seconds ==========================='
E           and: u''
E       remains unmatched: '*W293*'

/Users/romanlevin/workspace/pytest-flake8/test_flake8.py:61: Failed
------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_w293w2920, inifile:
plugins: flake8-0.8.1
collected 1 item

test_w293w292.py F

=================================== FAILURES ===================================
_________________________________ FLAKE8-check _________________________________
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest
    self.statistics)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file
    app.find_plugins()
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins
    self.prelim_opts.config,
E   AttributeError: 'NoneType' object has no attribute 'config'
=========================== 1 failed in 0.05 seconds ===========================
______________________________________________________________________________________ TestIgnores.test_mtime_caching ______________________________________________________________________________________

self = <test_flake8.TestIgnores instance at 0x10b55f9e0>, testdir = <Testdir local('/private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_mtime_caching0')>
example = local('/private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_mtime_caching0/test_mtime_caching.py')

    def test_mtime_caching(self, testdir, example):
        testdir.tmpdir.ensure("hello.py")
        result = testdir.runpytest("--flake8", )
        result.stdout.fnmatch_lines([
            # "*plugins*flake8*",
            "*W293*",
            "*W292*",
>           "*1 failed*",
        ])
E       Failed: nomatch: '*W293*'
E           and: u'============================= test session starts =============================='
E           and: u'platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0'
E           and: u'rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_mtime_caching0, inifile:'
E           and: u'plugins: flake8-0.8.1'
E           and: u'collected 2 items'
E           and: u''
E           and: u'hello.py F'
E           and: u'test_mtime_caching.py F'
E           and: u''
E           and: u'=================================== FAILURES ==================================='
E           and: u'_________________________________ FLAKE8-check _________________________________'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest'
E           and: u'    self.statistics)'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call'
E           and: u'    res = func(*args, **kwargs)'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file'
E           and: u'    app.find_plugins()'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins'
E           and: u'    self.prelim_opts.config,'
E           and: u"E   AttributeError: 'NoneType' object has no attribute 'config'"
E           and: u'_________________________________ FLAKE8-check _________________________________'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest'
E           and: u'    self.statistics)'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call'
E           and: u'    res = func(*args, **kwargs)'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file'
E           and: u'    app.find_plugins()'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins'
E           and: u'    self.prelim_opts.config,'
E           and: u"E   AttributeError: 'NoneType' object has no attribute 'config'"
E           and: u'=========================== 2 failed in 0.09 seconds ==========================='
E           and: u''
E       remains unmatched: '*W293*'

/Users/romanlevin/workspace/pytest-flake8/test_flake8.py:72: Failed
------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_mtime_caching0, inifile:
plugins: flake8-0.8.1
collected 2 items

hello.py F
test_mtime_caching.py F

=================================== FAILURES ===================================
_________________________________ FLAKE8-check _________________________________
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest
    self.statistics)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file
    app.find_plugins()
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins
    self.prelim_opts.config,
E   AttributeError: 'NoneType' object has no attribute 'config'
_________________________________ FLAKE8-check _________________________________
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest
    self.statistics)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file
    app.find_plugins()
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins
    self.prelim_opts.config,
E   AttributeError: 'NoneType' object has no attribute 'config'
=========================== 2 failed in 0.09 seconds ===========================
_____________________________________________________________________________________________ test_ok_verbose ______________________________________________________________________________________________

testdir = <Testdir local('/private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_ok_verbose0')>

    def test_ok_verbose(testdir):
        p = testdir.makepyfile("""
            class AClass:
                pass
        """)
        p = p.write(p.read() + "\n")
        result = testdir.runpytest("--flake8", "--verbose")
        result.stdout.fnmatch_lines([
            "*test_ok_verbose*",
        ])
>       assert result.ret == 0
E       assert 1 == 0
E        +  where 1 = <_pytest.pytester.RunResult instance at 0x10b4ff488>.ret

/Users/romanlevin/workspace/pytest-flake8/test_flake8.py:117: AssertionError
------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0 -- /Users/romanlevin/workspace/pytest-flake8/.tox/py27/bin/python2.7
cachedir: .cache
rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_ok_verbose0, inifile:
plugins: flake8-0.8.1
collecting ... collected 1 item

test_ok_verbose.py FAILED

=================================== FAILURES ===================================
_________________________________ FLAKE8-check _________________________________
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest
    self.statistics)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file
    app.find_plugins()
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins
    self.prelim_opts.config,
E   AttributeError: 'NoneType' object has no attribute 'config'
=========================== 1 failed in 0.05 seconds ===========================
____________________________________________________________________________________________ test_keyword_match ____________________________________________________________________________________________

testdir = <Testdir local('/private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_keyword_match0')>

    def test_keyword_match(testdir):
        testdir.makepyfile("""
            def test_hello():
                a=[ 1,123]
                #
        """)
        result = testdir.runpytest("--flake8", "-mflake8")
        result.stdout.fnmatch_lines([
            "*E201*",
>           "*1 failed*",
        ])
E       Failed: nomatch: '*E201*'
E           and: u'============================= test session starts =============================='
E           and: u'platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0'
E           and: u'rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_keyword_match0, inifile:'
E           and: u'plugins: flake8-0.8.1'
E           and: u'collected 2 items'
E           and: u''
E           and: u'test_keyword_match.py F'
E           and: u''
E           and: u'=================================== FAILURES ==================================='
E           and: u'_________________________________ FLAKE8-check _________________________________'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest'
E           and: u'    self.statistics)'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call'
E           and: u'    res = func(*args, **kwargs)'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file'
E           and: u'    app.find_plugins()'
E           and: u'/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins'
E           and: u'    self.prelim_opts.config,'
E           and: u"E   AttributeError: 'NoneType' object has no attribute 'config'"
E           and: u'============================== 1 tests deselected =============================='
E           and: u'==================== 1 failed, 1 deselected in 0.05 seconds ===================='
E           and: u''
E       remains unmatched: '*E201*'

/Users/romanlevin/workspace/pytest-flake8/test_flake8.py:129: Failed
------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_keyword_match0, inifile:
plugins: flake8-0.8.1
collected 2 items

test_keyword_match.py F

=================================== FAILURES ===================================
_________________________________ FLAKE8-check _________________________________
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:115: in runtest
    self.statistics)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/py/_io/capture.py:150: in call
    res = func(*args, **kwargs)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:180: in check_file
    app.find_plugins()
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/flake8/main/application.py:176: in find_plugins
    self.prelim_opts.config,
E   AttributeError: 'NoneType' object has no attribute 'config'
============================== 1 tests deselected ==============================
==================== 1 failed, 1 deselected in 0.05 seconds ====================
_______________________________________________________________________________________________ test_strict ________________________________________________________________________________________________

testdir = <Testdir local('/private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_strict0')>

    def test_strict(testdir):
        testdir.makepyfile("")
        result = testdir.runpytest("--strict", "--flake8")
>       assert result.ret == 0
E       assert 2 == 0
E        +  where 2 = <_pytest.pytester.RunResult instance at 0x10b69fa28>.ret

/Users/romanlevin/workspace/pytest-flake8/test_flake8.py:154: AssertionError
------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------
============================= test session starts ==============================
platform darwin -- Python 2.7.14, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: /private/var/folders/kd/6m65nq_96nn4sz2ft_1rgzq80000gp/T/pytest-of-romanlevin/pytest-6/testdir/test_strict0, inifile:
plugins: flake8-0.8.1
collected 0 items / 1 errors

==================================== ERRORS ====================================
______________________________ ERROR collecting  _______________________________
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:71: in pytest_collect_file
    statistics=config._flake8statistics)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/pytest_flake8.py:89: in __init__
    self.add_marker("flake8")
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/_pytest/main.py:402: in add_marker
    marker = getattr(MARK_GEN, marker)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/_pytest/mark.py:264: in __getattr__
    self._check(name)
/Users/romanlevin/workspace/pytest-flake8/.tox/py27/lib/python2.7/site-packages/_pytest/mark.py:279: in _check
    raise AttributeError("%r not a registered marker" % (name,))
E   AttributeError: 'flake8' not a registered marker
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.28 seconds ============================
============================================================================== 6 failed, 4 passed, 3 skipped in 0.97 seconds ===============================================================================
ERROR: InvocationError: '/Users/romanlevin/workspace/pytest-flake8/.tox/py27/bin/py.test --junitxml=/Users/romanlevin/workspace/pytest-flake8/.tox/py27/log/junit-py27.xml'
_________________________________________________________________________________________________ summary __________________________________________________________________________________________________
ERROR:   py27: commands failed