Skip to content

Commit

Permalink
Merge pull request #78 from carsongee/rc/0.13.0
Browse files Browse the repository at this point in the history
Rc/0.13.0
  • Loading branch information
carsongee authored Nov 26, 2018
2 parents 33f0ae0 + a93b59d commit 2cb3191
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 15 deletions.
16 changes: 11 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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 ."
Expand Down
9 changes: 8 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
<https://github.com/heoga>`_

0.12.3
~~~~~~

Expand Down
15 changes: 9 additions & 6 deletions pytest_pylint.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,7 +18,6 @@

class PyLintException(Exception):
"""Exception to raise if a file has a specified pylint error"""
pass


class ProgrammaticReporter(BaseReporter):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[aliases]
test=pytest
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
29 changes: 28 additions & 1 deletion test_pytest_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py27,py34,py35,py36
envlist = py27,py34,py35,py36,py37
skip_missing_interpreters =
true
[testenv]
Expand Down

0 comments on commit 2cb3191

Please sign in to comment.