gh-111609: Test end_offset in SyntaxError subclass (#127830)

Test `end_offset` in SyntaxError subclass
This commit is contained in:
Nice Zombies 2024-12-11 19:32:54 +01:00 committed by GitHub
parent bc262de06b
commit e8f4e272cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2274,6 +2274,21 @@ class SyntaxErrorTests(unittest.TestCase):
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 = (