Skip to content
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

stepwise: report status via pytest_report_collectionfinish #4993

Merged
merged 1 commit into from
Mar 28, 2019
Merged
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 changelog/4993.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The stepwise plugin reports status information now.
16 changes: 14 additions & 2 deletions src/_pytest/stepwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def pytest_addoption(parser):
"--stepwise",
action="store_true",
dest="stepwise",
help="exit on test fail and continue from last failing test next time",
help="exit on test failure and continue from last failing test next time",
)
group.addoption(
"--stepwise-skip",
Expand Down Expand Up @@ -37,7 +37,10 @@ def pytest_sessionstart(self, session):
self.session = session

def pytest_collection_modifyitems(self, session, config, items):
if not self.active or not self.lastfailed:
if not self.active:
return
if not self.lastfailed:
self.report_status = "no previously failed tests, not skipping."
return

already_passed = []
Expand All @@ -54,7 +57,12 @@ def pytest_collection_modifyitems(self, session, config, items):
# If the previously failed test was not found among the test items,
# do not skip any tests.
if not found:
self.report_status = "previously failed test not found, not skipping."
already_passed = []
else:
self.report_status = "skipping {} already passed items.".format(
len(already_passed)
)

for item in already_passed:
items.remove(item)
Expand Down Expand Up @@ -94,6 +102,10 @@ def pytest_runtest_logreport(self, report):
if report.nodeid == self.lastfailed:
self.lastfailed = None

def pytest_report_collectionfinish(self):
if self.active and self.config.getoption("verbose") >= 0:
return "stepwise: %s" % self.report_status

def pytest_sessionfinish(self, session):
if self.active:
self.config.cache.set("cache/stepwise", self.lastfailed)
Expand Down