* #9062 - Allow `--stepwise-skip` to implicitly enable `--stepwise` * Update changelog/9062.improvement.rst Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com> Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
parent
af42e7154a
commit
740abd9684
|
@ -0,0 +1 @@
|
||||||
|
``--stepwise-skip`` now implicitly enables ``--stepwise`` and can be used on its own.
|
|
@ -386,4 +386,4 @@ than speed.
|
||||||
Stepwise
|
Stepwise
|
||||||
--------
|
--------
|
||||||
|
|
||||||
As an alternative to ``--lf -x``, especially for cases where you expect a large part of the test suite will fail, ``--sw``, ``--stepwise`` allows you to fix them one at a time. The test suite will run until the first failure and then stop. At the next invocation, tests will continue from the last failing test and then run until the next failing test. You may use the ``--stepwise-skip`` option to ignore one failing test and stop the test execution on the second failing test instead. This is useful if you get stuck on a failing test and just want to ignore it until later.
|
As an alternative to ``--lf -x``, especially for cases where you expect a large part of the test suite will fail, ``--sw``, ``--stepwise`` allows you to fix them one at a time. The test suite will run until the first failure and then stop. At the next invocation, tests will continue from the last failing test and then run until the next failing test. You may use the ``--stepwise-skip`` option to ignore one failing test and stop the test execution on the second failing test instead. This is useful if you get stuck on a failing test and just want to ignore it until later. Providing ``--stepwise-skip`` will also enable ``--stepwise`` implicitly.
|
||||||
|
|
|
@ -31,13 +31,16 @@ def pytest_addoption(parser: Parser) -> None:
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=False,
|
default=False,
|
||||||
dest="stepwise_skip",
|
dest="stepwise_skip",
|
||||||
help="ignore the first failing test but stop on the next failing test",
|
help="ignore the first failing test but stop on the next failing test.\n"
|
||||||
|
"implicitly enables --stepwise.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl
|
@pytest.hookimpl
|
||||||
def pytest_configure(config: Config) -> None:
|
def pytest_configure(config: Config) -> None:
|
||||||
# We should always have a cache as cache provider plugin uses tryfirst=True
|
if config.option.stepwise_skip:
|
||||||
|
# allow --stepwise-skip to work on it's own merits.
|
||||||
|
config.option.stepwise = True
|
||||||
if config.getoption("stepwise"):
|
if config.getoption("stepwise"):
|
||||||
config.pluginmanager.register(StepwisePlugin(config), "stepwiseplugin")
|
config.pluginmanager.register(StepwisePlugin(config), "stepwiseplugin")
|
||||||
|
|
||||||
|
|
|
@ -248,3 +248,33 @@ def test_xfail_handling(pytester: Pytester, monkeypatch: MonkeyPatch) -> None:
|
||||||
"* 2 passed, 1 deselected, 1 xfailed in *",
|
"* 2 passed, 1 deselected, 1 xfailed in *",
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_stepwise_skip_is_independent(pytester: Pytester) -> None:
|
||||||
|
pytester.makepyfile(
|
||||||
|
"""
|
||||||
|
def test_one():
|
||||||
|
assert False
|
||||||
|
|
||||||
|
def test_two():
|
||||||
|
assert False
|
||||||
|
|
||||||
|
def test_three():
|
||||||
|
assert False
|
||||||
|
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = pytester.runpytest("--tb", "no", "--stepwise-skip")
|
||||||
|
result.assert_outcomes(failed=2)
|
||||||
|
result.stdout.fnmatch_lines(
|
||||||
|
[
|
||||||
|
"FAILED test_stepwise_skip_is_independent.py::test_one - assert False",
|
||||||
|
"FAILED test_stepwise_skip_is_independent.py::test_two - assert False",
|
||||||
|
"*Interrupted: Test failed, continuing from this test next run.*",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_sw_skip_help(pytester: Pytester) -> None:
|
||||||
|
result = pytester.runpytest("-h")
|
||||||
|
result.stdout.fnmatch_lines("*implicitly enables --stepwise.")
|
||||||
|
|
Loading…
Reference in New Issue