Skip to content

Commit

Permalink
Allow execution without cacheprovider
Browse files Browse the repository at this point in the history
If caching has been explicityly disabled, allow running.

Fixes #16
  • Loading branch information
tholo committed Oct 18, 2016
1 parent 0d98a90 commit 86fea89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.8
---

- Allow running with not cacheprovider
- Modernize use of fixtures in tests

0.7
---

Expand Down
13 changes: 9 additions & 4 deletions pytest_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def pytest_configure(config):
config._flake8showshource = config.getini("flake8-show-source")
config._flake8statistics = config.getini("flake8-statistics")
config._flake8exts = config.getini("flake8-extensions")
config._flake8mtimes = config.cache.get(HISTKEY, {})
if hasattr(config, 'cache'):
config._flake8mtimes = config.cache.get(HISTKEY, {})


def pytest_collect_file(path, parent):
Expand Down Expand Up @@ -93,7 +94,10 @@ def __init__(self, path, parent, flake8ignore, maxlength,
self.statistics = statistics

def setup(self):
flake8mtimes = self.config._flake8mtimes
if hasattr(self.config, "_flake8mtimes"):
flake8mtimes = self.config._flake8mtimes
else:
flake8mtimes = {}
self._flake8mtime = self.fspath.mtime()
old = flake8mtimes.get(str(self.fspath), (0, []))
if old == [self._flake8mtime, self.flake8ignore]:
Expand All @@ -113,8 +117,9 @@ def runtest(self):
raise Flake8Error(out, err)
# update mtime only if test passed
# otherwise failures would not be re-run next time
self.config._flake8mtimes[str(self.fspath)] = (self._flake8mtime,
self.flake8ignore)
if hasattr(self.config, "_flake8mtimes"):
self.config._flake8mtimes[str(self.fspath)] = (self._flake8mtime,
self.flake8ignore)

def repr_failure(self, excinfo):
if excinfo.errisinstance(Flake8Error):
Expand Down

0 comments on commit 86fea89

Please sign in to comment.