diff options
| author | Pablo Galindo <Pablogsal@gmail.com> | 2020-04-21 01:53:04 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-21 01:53:04 +0100 |
| commit | 11a7f158ef51b0edcde3c3d9215172354e385877 (patch) | |
| tree | 3bb7e125dce1a522ccbbe1ffbd14204c71bc852e /Lib/test/test_exceptions.py | |
| parent | 6a9e80a93148b13e4d3bceaab5ea1804ab0e64d5 (diff) | |
| download | cpython-git-11a7f158ef51b0edcde3c3d9215172354e385877.tar.gz | |
bpo-40335: Correctly handle multi-line strings in tokenize error scenarios (GH-19619)
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Diffstat (limited to 'Lib/test/test_exceptions.py')
| -rw-r--r-- | Lib/test/test_exceptions.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index d6739f1866..8c4a2882ba 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -188,7 +188,7 @@ class ExceptionTests(unittest.TestCase): if not isinstance(src, str): src = src.decode(encoding, 'replace') line = src.split('\n')[lineno-1] - self.assertEqual(cm.exception.text.rstrip('\n'), line) + self.assertIn(line, cm.exception.text) check('def fact(x):\n\treturn x!\n', 2, 10) check('1 +\n', 1, 4) @@ -217,6 +217,16 @@ class ExceptionTests(unittest.TestCase): check(b'\xce\xb1 = 0xI', 1, 6) check(b'# -*- coding: iso8859-7 -*-\n\xe1 = 0xI', 2, 6, encoding='iso8859-7') + check(b"""if 1: + def foo(): + ''' + + def bar(): + pass + + def baz(): + '''quux''' + """, 9, 20) # Errors thrown by symtable.c check('x = [(yield i) for i in range(3)]', 1, 5) |
