Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Weather: broken clouds
  • Loading branch information
anitahammer committed Apr 8, 2024
1 parent 95fa59f commit c0ffee4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion testing/test_collection.py
Expand Up @@ -6,7 +6,7 @@
import sys
import tempfile
import textwrap
from typing import List
from typing import List, Type

from _pytest.assertion.util import running_on_ci
from _pytest.config import ExitCode
Expand Down Expand Up @@ -1857,3 +1857,23 @@ def test_do_not_collect_symlink_siblings(
# Ensure we collect it only once if we pass the symlinked directory.
result = pytester.runpytest(symlink_path, "-sv")
result.assert_outcomes(passed=1)


@pytest.mark.parametrize("exception_class", (KeyboardInterrupt, SystemExit))
def test_respect_system_exceptions(
pytester: Pytester, exception_class: Type[BaseException]
):
ensure_file(pytester.path / "test_bar.py").write_text(
"raise SystemError()", encoding="UTF-8"
)
ensure_file(pytester.path / "test_baz.py").write_text(
f"raise {exception_class.__name__}()", encoding="UTF-8"
)
ensure_file(pytester.path / "test_foo.py").write_text(
"raise NotImplementedError()", encoding="UTF-8"
)

result = pytester.runpytest_subprocess()
result.stderr.fnmatch_lines(["*SystemError*"])
result.stderr.fnmatch_lines([f"*{exception_class.__name__}*"])
result.stderr.no_fnmatch_line("*NotImplementedError*")

0 comments on commit c0ffee4

Please sign in to comment.