Skip to content

Commit d8ef86a

Browse files
authored
Merge pull request #4993 from blueyed/stepwise-report
stepwise: report status via pytest_report_collectionfinish
2 parents a9fe1e1 + 94a2e3d commit d8ef86a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

changelog/4993.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The stepwise plugin reports status information now.

src/_pytest/stepwise.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def pytest_addoption(parser):
88
"--stepwise",
99
action="store_true",
1010
dest="stepwise",
11-
help="exit on test fail and continue from last failing test next time",
11+
help="exit on test failure and continue from last failing test next time",
1212
)
1313
group.addoption(
1414
"--stepwise-skip",
@@ -37,7 +37,10 @@ def pytest_sessionstart(self, session):
3737
self.session = session
3838

3939
def pytest_collection_modifyitems(self, session, config, items):
40-
if not self.active or not self.lastfailed:
40+
if not self.active:
41+
return
42+
if not self.lastfailed:
43+
self.report_status = "no previously failed tests, not skipping."
4144
return
4245

4346
already_passed = []
@@ -54,7 +57,12 @@ def pytest_collection_modifyitems(self, session, config, items):
5457
# If the previously failed test was not found among the test items,
5558
# do not skip any tests.
5659
if not found:
60+
self.report_status = "previously failed test not found, not skipping."
5761
already_passed = []
62+
else:
63+
self.report_status = "skipping {} already passed items.".format(
64+
len(already_passed)
65+
)
5866

5967
for item in already_passed:
6068
items.remove(item)
@@ -94,6 +102,10 @@ def pytest_runtest_logreport(self, report):
94102
if report.nodeid == self.lastfailed:
95103
self.lastfailed = None
96104

105+
def pytest_report_collectionfinish(self):
106+
if self.active and self.config.getoption("verbose") >= 0:
107+
return "stepwise: %s" % self.report_status
108+
97109
def pytest_sessionfinish(self, session):
98110
if self.active:
99111
self.config.cache.set("cache/stepwise", self.lastfailed)

0 commit comments

Comments
 (0)