File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 6
6
import sys
7
7
import tempfile
8
8
import textwrap
9
- from typing import List
9
+ from typing import List , Type
10
10
11
11
from _pytest .assertion .util import running_on_ci
12
12
from _pytest .config import ExitCode
@@ -1857,3 +1857,23 @@ def test_do_not_collect_symlink_siblings(
1857
1857
# Ensure we collect it only once if we pass the symlinked directory.
1858
1858
result = pytester .runpytest (symlink_path , "-sv" )
1859
1859
result .assert_outcomes (passed = 1 )
1860
+
1861
+
1862
+ @pytest .mark .parametrize ("exception_class" , (KeyboardInterrupt , SystemExit ))
1863
+ def test_respect_system_exceptions (
1864
+ pytester : Pytester , exception_class : Type [BaseException ]
1865
+ ):
1866
+ ensure_file (pytester .path / "test_bar.py" ).write_text (
1867
+ "raise SystemError()" , encoding = "UTF-8"
1868
+ )
1869
+ ensure_file (pytester .path / "test_baz.py" ).write_text (
1870
+ f"raise { exception_class .__name__ } ()" , encoding = "UTF-8"
1871
+ )
1872
+ ensure_file (pytester .path / "test_foo.py" ).write_text (
1873
+ "raise NotImplementedError()" , encoding = "UTF-8"
1874
+ )
1875
+
1876
+ result = pytester .runpytest_subprocess ()
1877
+ result .stderr .fnmatch_lines (["*SystemError*" ])
1878
+ result .stderr .fnmatch_lines ([f"*{ exception_class .__name__ } *" ])
1879
+ result .stderr .no_fnmatch_line ("*NotImplementedError*" )
You can’t perform that action at this time.
0 commit comments