Skip to content

Commit

Permalink
Check the cacheprovider of pytest, to fix #91
Browse files Browse the repository at this point in the history
  • Loading branch information
yanqd0 committed Jun 16, 2019
1 parent 706e3fb commit 9a918bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pytest_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,19 @@ class PylintPlugin(object):
# pylint: disable=too-few-public-methods

def __init__(self, config):
self.mtimes = config.cache.get(HISTKEY, {})
if hasattr(config, 'cache'):
self.mtimes = config.cache.get(HISTKEY, {})
else:
self.mtimes = {}

def pytest_sessionfinish(self, session):
"""
Save file mtimes to pytest cache.
:param _pytest.main.Session session: the pytest session object
"""
session.config.cache.set(HISTKEY, self.mtimes)
if hasattr(session.config, 'cache'):
session.config.cache.set(HISTKEY, self.mtimes)


def pytest_collect_file(path, parent):
Expand Down Expand Up @@ -234,6 +238,8 @@ def pytest_collection_finish(session):
result = lint.Run(args_list, reporter=reporter, exit=False)
except TypeError: # Handle pylint 2.0 API
result = lint.Run(args_list, reporter=reporter, do_exit=False)
except RuntimeError:
return
messages = result.linter.reporter.data
# Stores the messages in a dictionary for lookup in tests.
for message in messages:
Expand Down

0 comments on commit 9a918bd

Please sign in to comment.