summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tokenize.py
diff options
context:
space:
mode:
authorMarta Gómez Macías <mgmacias@google.com>2023-05-22 11:30:18 (GMT)
committerGitHub <noreply@github.com>2023-05-22 11:30:18 (GMT)
commit729b252241966f464cc46e176fb854dbcc5296cb (patch)
tree504b8a8c45364d456124dcbe79140bd0a5b7c2ad /Lib/test/test_tokenize.py
parent0a7796052acb9cec8b13f8d0a5f304f56f26ec5b (diff)
downloadcpython-729b252241966f464cc46e176fb854dbcc5296cb.zip
cpython-729b252241966f464cc46e176fb854dbcc5296cb.tar.gz
cpython-729b252241966f464cc46e176fb854dbcc5296cb.tar.bz2
gh-104741: Add line number attribute to indentation error exception (#104743)
Diffstat (limited to 'Lib/test/test_tokenize.py')
-rw-r--r--Lib/test/test_tokenize.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index dda7243..8e7ab3d 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -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