klen / pylama

Code audit tool for python.
MIT License
1.05k stars 99 forks source link

8.4.1: pytest is failing in `tests/test_linters.py::test_pylint` unit #238

Open kloczek opened 1 year ago

kloczek commented 1 year ago

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

Here is pytest output:

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pylama-8.4.1-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pylama-8.4.1-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -m 'not network' -q PYLINTHOME is now '/home/tkloczko/.cache/pylint' but obsolescent '/home/tkloczko/.pylint.d' is found; you can safely remove the latter ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.8.16, pytest-7.2.2, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/pylama-8.4.1, configfile: setup.cfg plugins: pylama-8.4.1 collected 35 items tests/test_config.py ... tests/test_config_toml.py . tests/test_context.py ....... tests/test_core.py ..... tests/test_linters.py ........F ========================================================================================= FAILURES ========================================================================================== ________________________________________________________________________________________ test_pylint ________________________________________________________________________________________ context = .fabric at 0x7f816cfd4ca0> def test_pylint(context): from pylama.lint import LINTERS pylint = LINTERS["pylint"] assert pylint ctx = context() pylint().run_check(ctx) errors = ctx.errors assert errors assert errors[0].number assert errors[0].col == 1 assert not errors[0].message.startswith(errors[0].number) # Test immutable params ctx = context() pylint().run_check(ctx) assert ctx.errors assert not ctx.linters_params ctx = context(args="--pylint-confidence=HIGH --ignore=C") pylint().run_check(ctx) > assert not ctx.errors E assert not [, ] E + where [, ] = .errors tests/test_linters.py:177: AssertionError ================================================================================== short test summary info ================================================================================== FAILED tests/test_linters.py::test_pylint - assert not [,

Here is list of installed modules in build env

```console Package Version ----------------------------- ----------------- alabaster 0.7.13 astroid 2.14.2 attrs 22.2.0 Babel 2.12.1 build 0.10.0 charset-normalizer 3.1.0 colorama 0.4.6 dill 0.3.5.1 distro 1.8.0 docutils 0.19 eradicate 2.1.0 exceptiongroup 1.0.0 future 0.18.3 gpg 1.18.0-unknown idna 3.4 imagesize 1.4.1 importlib-metadata 6.0.0 iniconfig 2.0.0 isort 5.11.2 Jinja2 3.1.2 lazy-object-proxy 1.9.0 libcomps 0.1.19 mando 0.7.0 MarkupSafe 2.1.2 mccabe 0.7.0 mypy 1.0.1 mypy-extensions 0.4.3 packaging 23.0 pip 22.3.1 platformdirs 2.6.0 pluggy 1.0.0 pycodestyle 2.9.1 pydocstyle 6.1.1 pyflakes 2.5.0 Pygments 2.14.0 pylint 2.16.1 pyproject_hooks 1.0.0 pytest 7.2.2 python-dateutil 2.8.2 pytz 2022.4 radon 5.1.0 requests 2.28.2 rpm 4.17.0 setuptools 65.6.3 six 1.16.0 snowballstemmer 2.2.0 Sphinx 6.1.3 sphinx-copybutton 0.5.1 sphinxcontrib-applehelp 1.0.4 sphinxcontrib-devhelp 1.0.2.dev20230202 sphinxcontrib-htmlhelp 2.0.0 sphinxcontrib-jsmath 1.0.1.dev20230128 sphinxcontrib-qthelp 1.0.3.dev20230128 sphinxcontrib-serializinghtml 1.1.5 toml 0.10.2 tomli 2.0.1 tomlkit 0.11.6 typing_extensions 4.4.0 urllib3 1.26.12 wheel 0.38.4 wrapt 1.14.1 zipp 3.15.0 ```
kloczek commented 1 year ago

I've tested 2093ce0a and pytest is failing in new place

========================================================================================= FAILURES ==========================================================================================
________________________________________________________________________________________ test_quotes ________________________________________________________________________________________

source = '#!/usr/bin/env python\n# coding: utf-8\n# (c) 2005 Divmod, Inc.  See LICENSE file for details\n\n\n# commented code\n...e expected\'\n\n    def bad_method(self):  # type: () -> None\n        """Return type mismatch."""\n        return 1\n'

    def test_quotes(source):
        from pylama.lint import LINTERS, Linter

>       quotes = LINTERS["quotes"]
E       KeyError: 'quotes'

tests/test_linters.py:198: KeyError
================================================================================== short test summary info ==================================================================================
FAILED tests/test_linters.py::test_quotes - KeyError: 'quotes'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================================================== 1 failed, 25 passed in 7.12s ================================================================================

and after --deselect tests/test_linters.py::test_quotes it fails in:

========================================================================================= FAILURES ==========================================================================================
_______________________________________________________________________________________ test_vulture ________________________________________________________________________________________

context = <function context.<locals>.fabric at 0x7f8307cd4700>

    def test_vulture(context):
        from pylama.lint import LINTERS

>       vulture = LINTERS["vulture"]
E       KeyError: 'vulture'

tests/test_linters.py:209: KeyError
================================================================================== short test summary info ==================================================================================
FAILED tests/test_linters.py::test_vulture - KeyError: 'vulture'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================== 1 failed, 25 passed, 1 deselected in 7.07s =========================================================================