Skip to content

Commit e48f4d9

Browse files
committed
Skip really in collection time
1 parent 2a01abd commit e48f4d9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

pytest_pylint.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,18 @@ def pytest_collect_file(path, parent):
198198
rel_path = get_rel_path(path.strpath, parent.session.fspath.strpath)
199199
session = parent.session
200200
if session.pylint_config is None:
201-
session.pylint_files.add(rel_path)
202201
# No pylintrc, therefore no ignores, so return the item.
203-
return PyLintItem(path, parent)
204-
205-
if include_file(rel_path, session.pylint_ignore,
206-
session.pylint_ignore_patterns):
207-
session.pylint_files.add(rel_path)
208-
return PyLintItem(
202+
item = PyLintItem(path, parent)
203+
elif include_file(rel_path, session.pylint_ignore,
204+
session.pylint_ignore_patterns):
205+
item = PyLintItem(
209206
path, parent, session.pylint_msg_template, session.pylintrc_file
210207
)
211-
return None
208+
else:
209+
return None
210+
if not item.should_skip:
211+
session.pylint_files.add(rel_path)
212+
return item
212213

213214

214215
def pytest_collection_finish(session):
@@ -268,11 +269,12 @@ def __init__(self, fspath, parent, msg_format=None, pylintrc_file=None):
268269

269270
self.pylintrc_file = pylintrc_file
270271
self.__mtime = self.fspath.mtime()
272+
prev_mtime = self.config.pylint.mtimes.get(self.nodeid, 0)
273+
self.should_skip = (prev_mtime == self.__mtime)
271274

272275
def setup(self):
273276
"""Mark unchanged files as SKIPPED."""
274-
previous = self.config.pylint.mtimes.get(self.nodeid, 0)
275-
if previous == self.__mtime:
277+
if self.should_skip:
276278
pytest.skip("file(s) previously passed pylint checks")
277279

278280
def runtest(self):

0 commit comments

Comments
 (0)