Skip to content

Refactor class StepwisePlugin. #4335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", [])