summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 316ade2..be81082 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -596,6 +596,24 @@ class TracebackErrorLocationCaretTestBase:
result_lines = self.get_exception(f_with_binary_operator)
self.assertEqual(result_lines, expected_error.splitlines())
+ def test_caret_for_binary_operators_with_spaces_and_parenthesis(self):
+ def f_with_binary_operator():
+ a = 1
+ b = ""
+ return ( a ) + b
+
+ lineno_f = f_with_binary_operator.__code__.co_firstlineno
+ expected_error = (
+ 'Traceback (most recent call last):\n'
+ f' File "{__file__}", line {self.callable_line}, in get_exception\n'
+ ' callable()\n'
+ f' File "{__file__}", line {lineno_f+3}, in f_with_binary_operator\n'
+ ' return ( a ) + b\n'
+ ' ~~~~~~~~~~^~~\n'
+ )
+ result_lines = self.get_exception(f_with_binary_operator)
+ self.assertEqual(result_lines, expected_error.splitlines())
+
def test_caret_for_subscript(self):
def f_with_subscript():
some_dict = {'x': {'y': None}}
@@ -630,6 +648,24 @@ class TracebackErrorLocationCaretTestBase:
result_lines = self.get_exception(f_with_subscript)
self.assertEqual(result_lines, expected_error.splitlines())
+ def test_caret_for_subscript_with_spaces_and_parenthesis(self):
+ def f_with_binary_operator():
+ a = []
+ b = c = 1
+ return b [ a ] + c
+
+ lineno_f = f_with_binary_operator.__code__.co_firstlineno
+ expected_error = (
+ 'Traceback (most recent call last):\n'
+ f' File "{__file__}", line {self.callable_line}, in get_exception\n'
+ ' callable()\n'
+ f' File "{__file__}", line {lineno_f+3}, in f_with_binary_operator\n'
+ ' return b [ a ] + c\n'
+ ' ~~~~~~^^^^^^^^^\n'
+ )
+ result_lines = self.get_exception(f_with_binary_operator)
+ self.assertEqual(result_lines, expected_error.splitlines())
+
def test_traceback_specialization_with_syntax_error(self):
bytecode = compile("1 / 0 / 1 / 2\n", TESTFN, "exec")