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