diff --git a/.travis.yml b/.travis.yml index 29c0308..848bc1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,15 @@ language: python -python: - - "2.7" - - "3.4" - - "3.5" - - "3.6" +dist: trusty +matrix: + include: + # See: https://github.com/travis-ci/travis-ci/issues/9815#issuecomment-411099620 + - python: 3.7 + dist: xenial + sudo: true + - python: 3.6 + - python: 3.5 + - python: 3.4 + - python: 2.7 install: - "pip install tox-travis tox==3.0.0 coveralls" - "pip install -e ." diff --git a/README.rst b/README.rst index 864a4f7..1ff1f4a 100644 --- a/README.rst +++ b/README.rst @@ -1,7 +1,7 @@ pytest pylint ------------- .. image:: https://img.shields.io/travis/carsongee/pytest-pylint.svg - :target: https://travis-ci.org/carsongee/orcoursetrion + :target: https://travis-ci.org/carsongee/pytest-pylint .. image:: https://img.shields.io/coveralls/carsongee/pytest-pylint.svg :target: https://coveralls.io/r/carsongee/pytest-pylint .. image:: https://img.shields.io/pypi/v/pytest-pylint.svg @@ -49,6 +49,13 @@ This code is heavily based on Releases ======== +0.13.0 +~~~~~~ + +- Python 3.7 compatibility verified +- Ignore paths no longer match partial names thanks to `heoga + `_ + 0.12.3 ~~~~~~ diff --git a/pytest_pylint.py b/pytest_pylint.py index 818e135..d663593 100644 --- a/pytest_pylint.py +++ b/pytest_pylint.py @@ -1,7 +1,5 @@ """Pylint plugin for py.test""" -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import print_function +from __future__ import absolute_import, print_function, unicode_literals from os import sep from os.path import exists, join, dirname import sys @@ -20,7 +18,6 @@ class PyLintException(Exception): """Exception to raise if a file has a specified pylint error""" - pass class ProgrammaticReporter(BaseReporter): @@ -135,6 +132,12 @@ def pytest_sessionstart(session): pass +def include_file(path, ignore_list): + """Checks if a file should be included in the collection.""" + parts = path.split(sep) + return not set(parts) & set(ignore_list) + + def pytest_collect_file(path, parent): """Collect files on which pylint should run""" config = parent.session.config @@ -149,7 +152,7 @@ def pytest_collect_file(path, parent): # No pylintrc, therefore no ignores, so return the item. return PyLintItem(path, parent) - if not any(basename in rel_path for basename in session.pylint_ignore): + if include_file(rel_path, session.pylint_ignore): session.pylint_files.add(rel_path) return PyLintItem( path, parent, session.pylint_msg_template, session.pylintrc_file @@ -197,7 +200,7 @@ class PyLintItem(pytest.Item, pytest.File): # pylint doesn't deal well with dynamic modules and there isn't an # astng plugin for pylint in pypi yet, so we'll have to disable # the checks. - # pylint: disable=no-member,super-on-old-class,abstract-method + # pylint: disable=no-member,abstract-method def __init__(self, fspath, parent, msg_format=None, pylintrc_file=None): super(PyLintItem, self).__init__(fspath, parent) diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..b7e4789 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[aliases] +test=pytest diff --git a/setup.py b/setup.py index 87e91de..ec9f871 100644 --- a/setup.py +++ b/setup.py @@ -13,13 +13,15 @@ description='pytest plugin to check source code with pylint', long_description=open("README.rst").read(), license='MIT', - version='0.12.3', + version='0.13.0', author='Carson Gee', author_email='x@carsongee.com', url='https://github.com/carsongee/pytest-pylint', py_modules=['pytest_pylint'], entry_points={'pytest11': ['pylint = pytest_pylint']}, install_requires=['pytest>=2.7', 'pylint>=1.4.5', 'six'], + setup_requires=['pytest-runner'], + tests_require=['mock', 'coverage', 'pytest-pep8'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', diff --git a/test_pytest_pylint.py b/test_pytest_pylint.py index c57294a..068b67d 100644 --- a/test_pytest_pylint.py +++ b/test_pytest_pylint.py @@ -15,7 +15,8 @@ def test_basic(testdir): assert 'Missing module docstring' in result.stdout.str() assert 'Unused import sys' in result.stdout.str() assert 'Final newline missing' in result.stdout.str() - assert 'passed' not in result.stdout.str() + assert 'passed, ' not in result.stdout.str() + assert '1 failed' in result.stdout.str() assert 'Linting files' in result.stdout.str() @@ -160,3 +161,29 @@ def test_no_multiple_jobs(testdir): testdir.runpytest('--pylint') assert run_mock.call_count == 1 assert '-j' not in run_mock.call_args[0][0] + + +def test_include_path(): + """ + Files should only be included in the list if none of the directories on + it's path, of the filename, match an entry in the ignore list. + """ + from pytest_pylint import include_file + ignore_list = [ + "first", "second", "third", "part", "base.py" + ] + # Default includes. + assert include_file("random", ignore_list) is True + assert include_file("random/filename", ignore_list) is True + assert include_file("random/other/filename", ignore_list) is True + # Basic ignore matches. + assert include_file("first/filename", ignore_list) is False + assert include_file("random/base.py", ignore_list) is False + # Part on paths. + assert include_file("part/second/filename.py", ignore_list) is False + assert include_file("random/part/filename.py", ignore_list) is False + assert include_file("random/second/part.py", ignore_list) is False + # Part as substring on paths. + assert include_file("part_it/other/filename.py", ignore_list) is True + assert include_file("random/part_it/filename.py", ignore_list) is True + assert include_file("random/other/part_it.py", ignore_list) is True diff --git a/tox.ini b/tox.ini index 2560295..4d7d938 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,py36 +envlist = py27,py34,py35,py36,py37 skip_missing_interpreters = true [testenv]