Skip to content

Commit 2cb3191

Browse files
authored
Merge pull request #78 from carsongee/rc/0.13.0
Rc/0.13.0
2 parents 33f0ae0 + a93b59d commit 2cb3191

File tree

7 files changed

+62
-15
lines changed

7 files changed

+62
-15
lines changed

.travis.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
language: python
2-
python:
3-
- "2.7"
4-
- "3.4"
5-
- "3.5"
6-
- "3.6"
2+
dist: trusty
3+
matrix:
4+
include:
5+
# See: https://github.com/travis-ci/travis-ci/issues/9815#issuecomment-411099620
6+
- python: 3.7
7+
dist: xenial
8+
sudo: true
9+
- python: 3.6
10+
- python: 3.5
11+
- python: 3.4
12+
- python: 2.7
713
install:
814
- "pip install tox-travis tox==3.0.0 coveralls"
915
- "pip install -e ."

README.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pytest pylint
22
-------------
33
.. image:: https://img.shields.io/travis/carsongee/pytest-pylint.svg
4-
:target: https://travis-ci.org/carsongee/orcoursetrion
4+
:target: https://travis-ci.org/carsongee/pytest-pylint
55
.. image:: https://img.shields.io/coveralls/carsongee/pytest-pylint.svg
66
:target: https://coveralls.io/r/carsongee/pytest-pylint
77
.. image:: https://img.shields.io/pypi/v/pytest-pylint.svg
@@ -49,6 +49,13 @@ This code is heavily based on
4949
Releases
5050
========
5151

52+
0.13.0
53+
~~~~~~
54+
55+
- Python 3.7 compatibility verified
56+
- Ignore paths no longer match partial names thanks to `heoga
57+
<https://github.com/heoga>`_
58+
5259
0.12.3
5360
~~~~~~
5461

pytest_pylint.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
"""Pylint plugin for py.test"""
2-
from __future__ import unicode_literals
3-
from __future__ import absolute_import
4-
from __future__ import print_function
2+
from __future__ import absolute_import, print_function, unicode_literals
53
from os import sep
64
from os.path import exists, join, dirname
75
import sys
@@ -20,7 +18,6 @@
2018

2119
class PyLintException(Exception):
2220
"""Exception to raise if a file has a specified pylint error"""
23-
pass
2421

2522

2623
class ProgrammaticReporter(BaseReporter):
@@ -135,6 +132,12 @@ def pytest_sessionstart(session):
135132
pass
136133

137134

135+
def include_file(path, ignore_list):
136+
"""Checks if a file should be included in the collection."""
137+
parts = path.split(sep)
138+
return not set(parts) & set(ignore_list)
139+
140+
138141
def pytest_collect_file(path, parent):
139142
"""Collect files on which pylint should run"""
140143
config = parent.session.config
@@ -149,7 +152,7 @@ def pytest_collect_file(path, parent):
149152
# No pylintrc, therefore no ignores, so return the item.
150153
return PyLintItem(path, parent)
151154

152-
if not any(basename in rel_path for basename in session.pylint_ignore):
155+
if include_file(rel_path, session.pylint_ignore):
153156
session.pylint_files.add(rel_path)
154157
return PyLintItem(
155158
path, parent, session.pylint_msg_template, session.pylintrc_file
@@ -197,7 +200,7 @@ class PyLintItem(pytest.Item, pytest.File):
197200
# pylint doesn't deal well with dynamic modules and there isn't an
198201
# astng plugin for pylint in pypi yet, so we'll have to disable
199202
# the checks.
200-
# pylint: disable=no-member,super-on-old-class,abstract-method
203+
# pylint: disable=no-member,abstract-method
201204
def __init__(self, fspath, parent, msg_format=None, pylintrc_file=None):
202205
super(PyLintItem, self).__init__(fspath, parent)
203206

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[aliases]
2+
test=pytest

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
description='pytest plugin to check source code with pylint',
1414
long_description=open("README.rst").read(),
1515
license='MIT',
16-
version='0.12.3',
16+
version='0.13.0',
1717
author='Carson Gee',
1818
author_email='[email protected]',
1919
url='https://github.com/carsongee/pytest-pylint',
2020
py_modules=['pytest_pylint'],
2121
entry_points={'pytest11': ['pylint = pytest_pylint']},
2222
install_requires=['pytest>=2.7', 'pylint>=1.4.5', 'six'],
23+
setup_requires=['pytest-runner'],
24+
tests_require=['mock', 'coverage', 'pytest-pep8'],
2325
classifiers=[
2426
'Development Status :: 5 - Production/Stable',
2527
'Intended Audience :: Developers',

test_pytest_pylint.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def test_basic(testdir):
1515
assert 'Missing module docstring' in result.stdout.str()
1616
assert 'Unused import sys' in result.stdout.str()
1717
assert 'Final newline missing' in result.stdout.str()
18-
assert 'passed' not in result.stdout.str()
18+
assert 'passed, ' not in result.stdout.str()
19+
assert '1 failed' in result.stdout.str()
1920
assert 'Linting files' in result.stdout.str()
2021

2122

@@ -160,3 +161,29 @@ def test_no_multiple_jobs(testdir):
160161
testdir.runpytest('--pylint')
161162
assert run_mock.call_count == 1
162163
assert '-j' not in run_mock.call_args[0][0]
164+
165+
166+
def test_include_path():
167+
"""
168+
Files should only be included in the list if none of the directories on
169+
it's path, of the filename, match an entry in the ignore list.
170+
"""
171+
from pytest_pylint import include_file
172+
ignore_list = [
173+
"first", "second", "third", "part", "base.py"
174+
]
175+
# Default includes.
176+
assert include_file("random", ignore_list) is True
177+
assert include_file("random/filename", ignore_list) is True
178+
assert include_file("random/other/filename", ignore_list) is True
179+
# Basic ignore matches.
180+
assert include_file("first/filename", ignore_list) is False
181+
assert include_file("random/base.py", ignore_list) is False
182+
# Part on paths.
183+
assert include_file("part/second/filename.py", ignore_list) is False
184+
assert include_file("random/part/filename.py", ignore_list) is False
185+
assert include_file("random/second/part.py", ignore_list) is False
186+
# Part as substring on paths.
187+
assert include_file("part_it/other/filename.py", ignore_list) is True
188+
assert include_file("random/part_it/filename.py", ignore_list) is True
189+
assert include_file("random/other/part_it.py", ignore_list) is True

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27,py34,py35,py36
2+
envlist = py27,py34,py35,py36,py37
33
skip_missing_interpreters =
44
true
55
[testenv]

0 commit comments

Comments
 (0)