klen / pylama

Code audit tool for python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

7.7.1: pytest suite is failing

kloczek opened this issue · comments

+ /usr/bin/python3 -Bm pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/tkloczko/rpmbuild/BUILD/pylama-7.7.1
plugins: pylama-7.7.1, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, cov-2.11.1, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, pyfakefs-4.4.0, freezegun-0.4.2, cases-3.4.6, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, mock-3.6.0, hypothesis-6.12.0, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, flaky-3.7.0, requests-mock-1.9.2, aiohttp-0.3.0
collected 20 items

tests/test_config.py .F..                                                                                                                                            [ 20%]
tests/test_core.py ...FFFF...                                                                                                                                        [ 70%]
tests/test_linters.py .F.F..                                                                                                                                         [100%]

================================================================================= FAILURES =================================================================================
____________________________________________________________________________ test_ignore_select ____________________________________________________________________________

    def test_ignore_select():
        options = parse_options()
        options.ignore = ['E301', 'D102']
        options.linters = ['pycodestyle', 'pydocstyle', 'pyflakes', 'mccabe']
        errors = run('dummy.py', options=options)
>       assert len(errors) == 32
E       assert 1 == 32
E        +  where 1 = len([<Error:  undefined>])

tests/test_config.py:31: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
IOError [Errno 2] No such file or directory: 'dummy.py'
______________________________________________________________________________ test_checkpath ______________________________________________________________________________

    def test_checkpath():
        path = op.abspath('dummy.py')
        options = parse_options([path])
        result = check_path(options)
>       assert result
E       assert []

tests/test_core.py:35: AssertionError
___________________________________________________________________________ test_linters_params ____________________________________________________________________________

    def test_linters_params():
        options = parse_options(linters='mccabe', config=False)
        options.linters_params['mccabe'] = dict(complexity=1)
        errors = run('dummy.py', options=options)
        assert len(errors) == 1

        options.linters_params['mccabe'] = dict(complexity=20)
        errors = run('dummy.py', options=options)
>       assert not errors
E       assert not [<Error:  undefined>]

tests/test_core.py:47: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
IOError [Errno 2] No such file or directory: 'dummy.py'
IOError [Errno 2] No such file or directory: 'dummy.py'
________________________________________________________________________________ test_sort _________________________________________________________________________________

    def test_sort():
        options = parse_options()
        options.sort = ['C', 'D']
        errors = run('dummy.py', options=options)
>       assert errors[0].type == 'C'
E       AssertionError: assert 'E' == 'C'
E         - C
E         + E

tests/test_core.py:54: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
IOError [Errno 2] No such file or directory: 'dummy.py'
________________________________________________________________________________ test_shell ________________________________________________________________________________

    def test_shell():
        errors = shell('-o dummy dummy.py'.split(), error=False)
>       assert errors
E       assert []

tests/test_core.py:59: AssertionError
______________________________________________________________________________ test_eradicate ______________________________________________________________________________

    def test_eradicate():
        eradicate = LINTERS.get('eradicate')
>       errors = eradicate.run('', code="\n".join([
            "#import os",
            "# from foo import junk",
            "#a = 3",
            "a = 4",
            "#foo(1, 2, 3)",
        ]))
E       AttributeError: 'NoneType' object has no attribute 'run'

tests/test_linters.py:16: AttributeError
_____________________________________________________________________________ test_pycodestyle _____________________________________________________________________________

    def test_pycodestyle():
        options = parse_options(linters=['pycodestyle'], config=False)
        assert len(options.linters) == 1
        errors = run('dummy.py', options=options)
        numbers = [error.number for error in errors]
>       assert len(errors) == 4
E       assert 1 == 4
E        +  where 1 = len([<Error:  undefined>])

tests/test_linters.py:42: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
IOError [Errno 2] No such file or directory: 'dummy.py'
========================================================================= short test summary info ==========================================================================
FAILED tests/test_config.py::test_ignore_select - assert 1 == 32
FAILED tests/test_core.py::test_checkpath - assert []
FAILED tests/test_core.py::test_linters_params - assert not [<Error:  undefined>]
FAILED tests/test_core.py::test_sort - AssertionError: assert 'E' == 'C'
FAILED tests/test_core.py::test_shell - assert []
FAILED tests/test_linters.py::test_eradicate - AttributeError: 'NoneType' object has no attribute 'run'
FAILED tests/test_linters.py::test_pycodestyle - assert 1 == 4
======================================================================= 7 failed, 13 passed in 0.76s =======================================================================

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

I've been using wrong testing metod. Here is update:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pylama-7.7.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pylama-7.7.1-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra tests
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/pylama-7.7.1, configfile: tox.ini
plugins: pylama-7.7.1, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0, asyncio-0.15.1, trio-0.7.0, httpbin-1.0.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0
collected 20 items

tests/test_config.py .F..
tests/test_core.py ......dummy.py:7:1: E265 block comment should start with '# ' [pycodestyle]
dummy.py:11:1: E265 block comment should start with '# ' [pycodestyle]
dummy.py:17:5: E301 expected 1 blank line, found 0 [pycodestyle]
dummy.py:32:80: E501 line too long (91 > 79 characters) [pycodestyle]
....
tests/test_linters.py .F....

================================================================================= FAILURES =================================================================================
____________________________________________________________________________ test_ignore_select ____________________________________________________________________________

    def test_ignore_select():
        options = parse_options()
        options.ignore = ['E301', 'D102']
        options.linters = ['pycodestyle', 'pydocstyle', 'pyflakes', 'mccabe']
        errors = run('dummy.py', options=options)
>       assert len(errors) == 32
E       assert 33 == 32
E        +  where 33 = len([<Error: D100 pydocstyle>, <Error: E265 pycodestyle>, <Error: E265 pycodestyle>, <Error: D101 pydocstyle>, <Error: D107 pydocstyle>, <Error: D105 pydocstyle>, ...])

tests/test_config.py:31: AssertionError
______________________________________________________________________________ test_eradicate ______________________________________________________________________________

    def test_eradicate():
        eradicate = LINTERS.get('eradicate')
>       errors = eradicate.run('', code="\n".join([
            "#import os",
            "# from foo import junk",
            "#a = 3",
            "a = 4",
            "#foo(1, 2, 3)",
        ]))
E       AttributeError: 'NoneType' object has no attribute 'run'

tests/test_linters.py:16: AttributeError
============================================================================= warnings summary =============================================================================
tests/test_core.py::test_checkpath
tests/test_core.py::test_sort
  /usr/lib/python3.8/site-packages/pylint/lint/run.py:362: DeprecationWarning: do_exit is deprecated and it is going to be removed in a future version.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
FAILED tests/test_config.py::test_ignore_select - assert 33 == 32
FAILED tests/test_linters.py::test_eradicate - AttributeError: 'NoneType' object has no attribute 'run'
================================================================= 2 failed, 18 passed, 2 warnings in 8.92s =================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.

@kloczek Thank you for the feedback. The issue has been fixed in the latest version (8.0.4).