summaryrefslogtreecommitdiff
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2021-10-20 20:55:46 -0700
committerGitHub <noreply@github.com>2021-10-20 20:55:46 -0700
commitc52338fc42353e8d0c6214e4c22427807439dfd5 (patch)
tree6da4bf5da5eb739aa48eab1850218d5726c45b10 /Lib/test/test_traceback.py
parent8f05ffb0534c2343fc45ad0e1d91ae1dc2d92b64 (diff)
parent2a9ab75af32b1ee9f210ae2a0718990687d0f79d (diff)
downloadcpython-git-enum-private-310.tar.gz
Merge branch '3.10' into enum-private-310enum-private-310
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index fabe5d01a9..ba03ce4629 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -51,6 +51,9 @@ class TracebackCases(unittest.TestCase):
def syntax_error_bad_indentation2(self):
compile(" print(2)", "?", "exec")
+ def tokenizer_error_with_caret_range(self):
+ compile("blech ( ", "?", "exec")
+
def test_caret(self):
err = self.get_exception_format(self.syntax_error_with_caret,
SyntaxError)
@@ -81,6 +84,13 @@ class TracebackCases(unittest.TestCase):
self.assertEqual(err[1].find("y"), err[2].find("^")) # in the right place
self.assertEqual(err[2].count("^"), len("y for y in range(30)"))
+ err = self.get_exception_format(self.tokenizer_error_with_caret_range,
+ SyntaxError)
+ self.assertIn("^", err[2]) # third line has caret
+ self.assertEqual(err[2].count('\n'), 1) # and no additional newline
+ self.assertEqual(err[1].find("("), err[2].find("^")) # in the right place
+ self.assertEqual(err[2].count("^"), 1)
+
def test_nocaret(self):
exc = SyntaxError("error", ("x.py", 23, None, "bad syntax"))
err = traceback.format_exception_only(SyntaxError, exc)