Skip to content

Commit e8f4e27

Browse files
authored
gh-111609: Test end_offset in SyntaxError subclass (#127830)
Test `end_offset` in SyntaxError subclass
1 parent bc262de commit e8f4e27

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_exceptions.py

+15
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,21 @@ def test_range_of_offsets(self):
22742274
self.assertIn(expected, err.getvalue())
22752275
the_exception = exc
22762276

2277+
def test_subclass(self):
2278+
class MySyntaxError(SyntaxError):
2279+
pass
2280+
2281+
try:
2282+
raise MySyntaxError("bad bad", ("bad.py", 1, 2, "abcdefg", 1, 7))
2283+
except SyntaxError as exc:
2284+
with support.captured_stderr() as err:
2285+
sys.__excepthook__(*sys.exc_info())
2286+
self.assertIn("""
2287+
File "bad.py", line 1
2288+
abcdefg
2289+
^^^^^
2290+
""", err.getvalue())
2291+
22772292
def test_encodings(self):
22782293
self.addCleanup(unlink, TESTFN)
22792294
source = (

0 commit comments

Comments
 (0)