MCPcopy
hub / github.com/pytest-dev/pytest / test_exitfirst

Function test_exitfirst

testing/test_subtests.py:949–971  ·  view source on GitHub ↗

Validate that when passing --exitfirst the test exits after the first failed subtest.

(pytester: pytest.Pytester)

Source from the content-addressed store, hash-verified

947
948
949def test_exitfirst(pytester: pytest.Pytester) -> None:
950 """Validate that when passing --exitfirst the test exits after the first failed subtest."""
951 pytester.makepyfile(
952 """
953 def test_foo(subtests):
954 with subtests.test("sub1"):
955 assert False
956
957 with subtests.test("sub2"):
958 assert False
959 """
960 )
961 result = pytester.runpytest("--exitfirst")
962 assert result.parseoutcomes()["failed"] == 2
963 result.stdout.fnmatch_lines(
964 [
965 "SUBFAILED*[[]sub1[]] *.py::test_foo - assert False*",
966 "FAILED *.py::test_foo - assert False",
967 "* stopping after 2 failures*",
968 ],
969 consecutive=True,
970 )
971 result.stdout.no_fnmatch_line("*sub2*") # sub2 not executed.
972
973
974def test_do_not_swallow_pytest_exit(pytester: pytest.Pytester) -> None:

Callers

nothing calls this directly

Calls 5

parseoutcomesMethod · 0.80
fnmatch_linesMethod · 0.80
no_fnmatch_lineMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected