Validate that when passing --exitfirst the test exits after the first failed subtest.
(pytester: pytest.Pytester)
| 947 | |
| 948 | |
| 949 | def 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 | |
| 974 | def test_do_not_swallow_pytest_exit(pytester: pytest.Pytester) -> None: |
nothing calls this directly
no test coverage detected