diff options
author | Batuhan Taskaya <batuhan@python.org> | 2021-07-15 23:38:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-15 23:38:11 (GMT) |
commit | 919ad537510fdc2c750109e0bc4eceea234324b2 (patch) | |
tree | 203dc2bd7d3beeb8623027e0fbead3addac15808 /Lib/test/test_traceback.py | |
parent | 074e7659f208051b6b973f7fdb654dd22b93aaa2 (diff) | |
download | cpython-919ad537510fdc2c750109e0bc4eceea234324b2.zip cpython-919ad537510fdc2c750109e0bc4eceea234324b2.tar.gz cpython-919ad537510fdc2c750109e0bc4eceea234324b2.tar.bz2 |
bpo-43950: make BinOp specializations more reliable (GH-27126)
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r-- | Lib/test/test_traceback.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 8baf38c..402f773 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -485,6 +485,44 @@ class TracebackErrorLocationCaretTests(unittest.TestCase): ) self.assertEqual(result_lines, expected_error.splitlines()) + def assertSpecialized(self, func, expected_specialization): + result_lines = self.get_exception(func) + specialization_line = result_lines[-1] + self.assertEqual(specialization_line.lstrip(), expected_specialization) + + def test_specialization_variations(self): + self.assertSpecialized(lambda: 1/0, + "~^~") + self.assertSpecialized(lambda: 1/0/3, + "~^~") + self.assertSpecialized(lambda: 1 / 0, + "~~^~~") + self.assertSpecialized(lambda: 1 / 0 / 3, + "~~^~~") + self.assertSpecialized(lambda: 1/ 0, + "~^~~") + self.assertSpecialized(lambda: 1/ 0/3, + "~^~~") + self.assertSpecialized(lambda: 1 / 0, + "~~~~~^~~~") + self.assertSpecialized(lambda: 1 / 0 / 5, + "~~~~~^~~~") + self.assertSpecialized(lambda: 1 /0, + "~~^~") + self.assertSpecialized(lambda: 1//0, + "~^^~") + self.assertSpecialized(lambda: 1//0//4, + "~^^~") + self.assertSpecialized(lambda: 1 // 0, + "~~^^~~") + self.assertSpecialized(lambda: 1 // 0 // 4, + "~~^^~~") + self.assertSpecialized(lambda: 1 //0, + "~~^^~") + self.assertSpecialized(lambda: 1// 0, + "~^^~~") + + @cpython_only @requires_debug_ranges() class CPythonTracebackErrorCaretTests(TracebackErrorLocationCaretTests): |