Skip to content

Commit

Permalink
Refactor class StepwisePlugin.
Browse files Browse the repository at this point in the history
Initialize class properties.
Check attributes before accessing them, LBYL.
  • Loading branch information
henrykironde committed Nov 8, 2018
1 parent 64762d2 commit d4d1bf4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ Samuel Dion-Girardeau
Samuele Pedroni
Sankt Petersbug
Segev Finer
Senyondo Henry
Serhii Mozghovyi
Simon Gomizelj
Skylar Downes
Expand Down
1 change: 1 addition & 0 deletions changelog/4304.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Possible bug with the 3.10.0 release
21 changes: 12 additions & 9 deletions src/_pytest/stepwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ def __init__(self, config):
self.config = config
self.active = config.getvalue("stepwise")
self.session = None

if self.active:
self.lastfailed = config.cache.get("cache/stepwise", None)
self.skip = config.getvalue("stepwise_skip")
self.lastfailed = None
self.skip = None
if hasattr(self.config, "cache"):
if self.active:
self.lastfailed = config.cache.get("cache/stepwise", None)
self.skip = config.getvalue("stepwise_skip")

def pytest_sessionstart(self, session):
self.session = session
Expand Down Expand Up @@ -95,8 +97,9 @@ def pytest_runtest_logreport(self, report):
self.lastfailed = None

def pytest_sessionfinish(self, session):
if self.active:
self.config.cache.set("cache/stepwise", self.lastfailed)
else:
# Clear the list of failing tests if the plugin is not active.
self.config.cache.set("cache/stepwise", [])
if hasattr(self.config, "cache"):
if self.active:
self.config.cache.set("cache/stepwise", self.lastfailed)
else:
# Clear the list of failing tests if the plugin is not active.
self.config.cache.set("cache/stepwise", [])

0 comments on commit d4d1bf4

Please sign in to comment.