doc/en/example/assertion/test_failures.py
raw| 1 | from __future__ import annotations |
| 2 | |
| 3 | import os.path |
| 4 | import shutil |
| 5 | |
| 6 | |
| 7 | failure_demo = os.path.join(os.path.dirname(__file__), "failure_demo.py") |
| 8 | pytest_plugins = ("pytester",) |
| 9 | |
| 10 | |
| 11 | def test_failure_demo_fails_properly(pytester): |
| 12 | target = pytester.path.joinpath(os.path.basename(failure_demo)) |
| 13 | shutil.copy(failure_demo, target) |
| 14 | result = pytester.runpytest(target, syspathinsert=True) |
| 15 | result.stdout.fnmatch_lines(["*44 failed*"]) |
| 16 | assert result.ret != 0 |