Skip to content

Commit 5f5a017

Browse files
nineteendomiss-islington
authored andcommitted
gh-111609: Test end_offset in SyntaxError subclass (GH-127830)
Test `end_offset` in SyntaxError subclass (cherry picked from commit e8f4e27) Co-authored-by: Nice Zombies <[email protected]>
1 parent 8b24d04 commit 5f5a017

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
@@ -2251,6 +2251,21 @@ def test_range_of_offsets(self):
22512251
self.assertIn(expected, err.getvalue())
22522252
the_exception = exc
22532253

2254+
def test_subclass(self):
2255+
class MySyntaxError(SyntaxError):
2256+
pass
2257+
2258+
try:
2259+
raise MySyntaxError("bad bad", ("bad.py", 1, 2, "abcdefg", 1, 7))
2260+
except SyntaxError as exc:
2261+
with support.captured_stderr() as err:
2262+
sys.__excepthook__(*sys.exc_info())
2263+
self.assertIn("""
2264+
File "bad.py", line 1
2265+
abcdefg
2266+
^^^^^
2267+
""", err.getvalue())
2268+
22542269
def test_encodings(self):
22552270
self.addCleanup(unlink, TESTFN)
22562271
source = (

0 commit comments

Comments
 (0)