diff --git a/changelog/4993.feature.rst b/changelog/4993.feature.rst new file mode 100644 index 000000000..b8e1ff494 --- /dev/null +++ b/changelog/4993.feature.rst @@ -0,0 +1 @@ +The stepwise plugin reports status information now. diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index 1efa2e7ca..68e53a31c 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -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", @@ -37,7 +37,10 @@ class StepwisePlugin: 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 = [] @@ -54,7 +57,12 @@ class StepwisePlugin: # 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) @@ -94,6 +102,10 @@ class StepwisePlugin: 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)