parent
0fc11b6f3c
commit
e2fa2b621c
|
@ -0,0 +1 @@
|
||||||
|
Fix ``--stepwise`` mode when the first file passed on the command-line fails to collect.
|
|
@ -29,6 +29,7 @@ class StepwisePlugin:
|
||||||
self.config = config
|
self.config = config
|
||||||
self.active = config.getvalue("stepwise")
|
self.active = config.getvalue("stepwise")
|
||||||
self.session = None
|
self.session = None
|
||||||
|
self.report_status = ""
|
||||||
|
|
||||||
if self.active:
|
if self.active:
|
||||||
self.lastfailed = config.cache.get("cache/stepwise", None)
|
self.lastfailed = config.cache.get("cache/stepwise", None)
|
||||||
|
@ -104,7 +105,7 @@ class StepwisePlugin:
|
||||||
self.lastfailed = None
|
self.lastfailed = None
|
||||||
|
|
||||||
def pytest_report_collectionfinish(self):
|
def pytest_report_collectionfinish(self):
|
||||||
if self.active and self.config.getoption("verbose") >= 0:
|
if self.active and self.config.getoption("verbose") >= 0 and self.report_status:
|
||||||
return "stepwise: %s" % self.report_status
|
return "stepwise: %s" % self.report_status
|
||||||
|
|
||||||
def pytest_sessionfinish(self, session):
|
def pytest_sessionfinish(self, session):
|
||||||
|
|
|
@ -157,14 +157,18 @@ def test_change_testfile(stepwise_testdir):
|
||||||
assert "test_success PASSED" in stdout
|
assert "test_success PASSED" in stdout
|
||||||
|
|
||||||
|
|
||||||
def test_stop_on_collection_errors(broken_testdir):
|
@pytest.mark.parametrize("broken_first", [True, False])
|
||||||
result = broken_testdir.runpytest(
|
def test_stop_on_collection_errors(broken_testdir, broken_first):
|
||||||
"-v",
|
"""Stop during collection errors. We have two possible messages depending on the order (#5444),
|
||||||
"--strict-markers",
|
so test both cases."""
|
||||||
"--stepwise",
|
files = ["working_testfile.py", "broken_testfile.py"]
|
||||||
"broken_testfile.py",
|
if broken_first:
|
||||||
"working_testfile.py",
|
files.reverse()
|
||||||
)
|
result = broken_testdir.runpytest("-v", "--strict-markers", "--stepwise", *files)
|
||||||
|
|
||||||
stdout = result.stdout.str()
|
if broken_first:
|
||||||
assert "errors during collection" in stdout
|
result.stdout.fnmatch_lines(
|
||||||
|
"*Error when collecting test, stopping test execution*"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
result.stdout.fnmatch_lines("*errors during collection*")
|
||||||
|
|
Loading…
Reference in New Issue