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