Ensure normal xfail is ignored, and strict xfail interrupts the session in sw mode (#5547)
(pytester: Pytester, monkeypatch: MonkeyPatch)
| 199 | |
| 200 | |
| 201 | def test_xfail_handling(pytester: Pytester, monkeypatch: MonkeyPatch) -> None: |
| 202 | """Ensure normal xfail is ignored, and strict xfail interrupts the session in sw mode |
| 203 | |
| 204 | (#5547) |
| 205 | """ |
| 206 | monkeypatch.setattr("sys.dont_write_bytecode", True) |
| 207 | |
| 208 | contents = """ |
| 209 | import pytest |
| 210 | def test_a(): pass |
| 211 | |
| 212 | @pytest.mark.xfail(strict={strict}) |
| 213 | def test_b(): assert {assert_value} |
| 214 | |
| 215 | def test_c(): pass |
| 216 | def test_d(): pass |
| 217 | """ |
| 218 | pytester.makepyfile(contents.format(assert_value="0", strict="False")) |
| 219 | result = pytester.runpytest("--sw", "-v") |
| 220 | result.stdout.fnmatch_lines( |
| 221 | [ |
| 222 | "*::test_a PASSED *", |
| 223 | "*::test_b XFAIL *", |
| 224 | "*::test_c PASSED *", |
| 225 | "*::test_d PASSED *", |
| 226 | "* 3 passed, 1 xfailed in *", |
| 227 | ] |
| 228 | ) |
| 229 | |
| 230 | pytester.makepyfile(contents.format(assert_value="1", strict="True")) |
| 231 | result = pytester.runpytest("--sw", "-v") |
| 232 | result.stdout.fnmatch_lines( |
| 233 | [ |
| 234 | "*::test_a PASSED *", |
| 235 | "*::test_b FAILED *", |
| 236 | "* Interrupted*", |
| 237 | "* 1 failed, 1 passed in *", |
| 238 | ] |
| 239 | ) |
| 240 | |
| 241 | pytester.makepyfile(contents.format(assert_value="0", strict="True")) |
| 242 | result = pytester.runpytest("--sw", "-v") |
| 243 | result.stdout.fnmatch_lines( |
| 244 | [ |
| 245 | "*::test_b XFAIL *", |
| 246 | "*::test_c PASSED *", |
| 247 | "*::test_d PASSED *", |
| 248 | "* 2 passed, 1 deselected, 1 xfailed in *", |
| 249 | ] |
| 250 | ) |
| 251 | |
| 252 | |
| 253 | def test_stepwise_skip_is_independent(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected