mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
gh-104741: Add line number attribute to indentation error exception (#104743)
This commit is contained in:
parent
0a7796052a
commit
729b252241
3 changed files with 20 additions and 8 deletions
|
@ -92,9 +92,18 @@ def k(x):
|
|||
readline = BytesIO(indent_error_file).readline
|
||||
with self.assertRaisesRegex(IndentationError,
|
||||
"unindent does not match any "
|
||||
"outer indentation level"):
|
||||
"outer indentation level") as e:
|
||||
for tok in tokenize(readline):
|
||||
pass
|
||||
self.assertEqual(e.exception.lineno, 3)
|
||||
self.assertEqual(e.exception.filename, '<string>')
|
||||
self.assertEqual(e.exception.end_lineno, None)
|
||||
self.assertEqual(e.exception.end_offset, None)
|
||||
self.assertEqual(
|
||||
e.exception.msg,
|
||||
'unindent does not match any outer indentation level')
|
||||
self.assertEqual(e.exception.offset, 9)
|
||||
self.assertEqual(e.exception.text, ' x += 5\n')
|
||||
|
||||
def test_int(self):
|
||||
# Ordinary integers and binary operators
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue