test_ok2/doc/en/example/assertion/test_failures.py

14 lines
427 B
Python
Raw Normal View History

2020-07-27 08:56:06 +08:00
import os.path
import shutil
2018-05-23 22:48:46 +08:00
2020-07-27 08:56:06 +08:00
failure_demo = os.path.join(os.path.dirname(__file__), "failure_demo.py")
pytest_plugins = ("pytester",)
2018-05-23 22:48:46 +08:00
def test_failure_demo_fails_properly(pytester):
target = pytester.path.joinpath(os.path.basename(failure_demo))
2020-07-27 08:56:06 +08:00
shutil.copy(failure_demo, target)
result = pytester.runpytest(target, syspathinsert=True)
2018-08-03 22:23:50 +08:00
result.stdout.fnmatch_lines(["*44 failed*"])
assert result.ret != 0