Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <nineteendo19d0@gmail.com>
  • Loading branch information
nineteendo authored and miss-islington committed Feb 21, 2025
commit 005bf394884e20c42a9aeed00c2b92376235e704
15 changes: 15 additions & 0 deletions Lib/test/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,21 @@ def test_range_of_offsets(self):
self.assertIn(expected, err.getvalue())
the_exception = exc

def test_subclass(self):
class MySyntaxError(SyntaxError):
pass

try:
raise MySyntaxError("bad bad", ("bad.py", 1, 2, "abcdefg", 1, 7))
except SyntaxError as exc:
with support.captured_stderr() as err:
sys.__excepthook__(*sys.exc_info())
self.assertIn("""
File "bad.py", line 1
abcdefg
^^^^^
""", err.getvalue())

def test_encodings(self):
self.addCleanup(unlink, TESTFN)
source = (
Expand Down