diff options
| author | Florent Xicluna <florent.xicluna@gmail.com> | 2014-01-22 00:33:59 (GMT) |
|---|---|---|
| committer | Florent Xicluna <florent.xicluna@gmail.com> | 2014-01-22 00:33:59 (GMT) |
| commit | edfd9addf6166cbc7406b95896d48cfdaf82adf7 (patch) | |
| tree | 02f085b06c364cb78a48988345860d435ad8534b /Lib/test/test_traceback.py | |
| parent | 70df667dfeb6b8600f3f0d34dfbf7a57d5205046 (diff) | |
| download | cpython-edfd9addf6166cbc7406b95896d48cfdaf82adf7.zip cpython-edfd9addf6166cbc7406b95896d48cfdaf82adf7.tar.gz cpython-edfd9addf6166cbc7406b95896d48cfdaf82adf7.tar.bz2 | |
Issue #17825: Cursor ^ is correctly positioned for SyntaxError and IndentationError.
Diffstat (limited to 'Lib/test/test_traceback.py')
| -rw-r--r-- | Lib/test/test_traceback.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 8076be8..d7b183a 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -35,6 +35,9 @@ class TracebackCases(unittest.TestCase): def syntax_error_bad_indentation(self): compile("def spam():\n print 1\n print 2", "?", "exec") + def syntax_error_bad_indentation2(self): + compile(" print(2)", "?", "exec") + def test_caret(self): err = self.get_exception_format(self.syntax_error_with_caret, SyntaxError) @@ -111,6 +114,13 @@ def test(): os.unlink(os.path.join(testdir, f)) os.rmdir(testdir) + err = self.get_exception_format(self.syntax_error_bad_indentation2, + IndentationError) + self.assertEqual(len(err), 4) + self.assertEqual(err[1].strip(), "print(2)") + self.assertIn("^", err[2]) + self.assertEqual(err[1].find("p"), err[2].find("^")) + def test_base_exception(self): # Test that exceptions derived from BaseException are formatted right e = KeyboardInterrupt() |
