MCPcopy
hub / github.com/pytest-dev/pytest / test_respect_system_exceptions

Function test_respect_system_exceptions

testing/test_collection.py:1898–1918  ·  view source on GitHub ↗
(
    pytester: Pytester,
    exception_class: type[BaseException],
    msg: str,
)

Source from the content-addressed store, hash-verified

1896 ],
1897)
1898def test_respect_system_exceptions(
1899 pytester: Pytester,
1900 exception_class: type[BaseException],
1901 msg: str,
1902):
1903 head = "Before exception"
1904 tail = "After exception"
1905 ensure_file(pytester.path / "test_eggs.py").write_text(
1906 f"print('{head}')", encoding="UTF-8"
1907 )
1908 ensure_file(pytester.path / "test_ham.py").write_text(
1909 f"raise {exception_class.__name__}()", encoding="UTF-8"
1910 )
1911 ensure_file(pytester.path / "test_spam.py").write_text(
1912 f"print('{tail}')", encoding="UTF-8"
1913 )
1914
1915 result = pytester.runpytest_subprocess("-s")
1916 result.stdout.fnmatch_lines([f"*{head}*"])
1917 result.stdout.fnmatch_lines([msg])
1918 result.stdout.no_fnmatch_line(f"*{tail}*")
1919
1920
1921def test_yield_disallowed_in_tests(pytester: Pytester):

Callers

nothing calls this directly

Calls 5

ensure_fileFunction · 0.85
write_textMethod · 0.80
fnmatch_linesMethod · 0.80
no_fnmatch_lineMethod · 0.80
runpytest_subprocessMethod · 0.45

Tested by

no test coverage detected