diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-09-20 21:47:37 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-09-20 21:47:37 (GMT) |
commit | 26d64aeee4face9f6929f4207647b0052ad27c36 (patch) | |
tree | 347364d7757e813e24962ff7cf52755b8c3b9c2c | |
parent | b0b384b7c0333bf1183cd6f90c0a3f9edaadd6b9 (diff) | |
download | cpython-26d64aeee4face9f6929f4207647b0052ad27c36.zip cpython-26d64aeee4face9f6929f4207647b0052ad27c36.tar.gz cpython-26d64aeee4face9f6929f4207647b0052ad27c36.tar.bz2 |
rewrite nocaret test to not rely on a specific SyntaxError
-rw-r--r-- | Lib/test/badsyntax_nocaret.py | 2 | ||||
-rw-r--r-- | Lib/test/test_traceback.py | 15 |
2 files changed, 4 insertions, 13 deletions
diff --git a/Lib/test/badsyntax_nocaret.py b/Lib/test/badsyntax_nocaret.py deleted file mode 100644 index 01ec9ea..0000000 --- a/Lib/test/badsyntax_nocaret.py +++ /dev/null @@ -1,2 +0,0 @@ -def f(x): - [x for x in x] = x diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 3db8864..11bdf58 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -5,7 +5,7 @@ from io import StringIO import sys import unittest import re -from test.support import run_unittest, is_jython, Error, captured_output +from test.support import run_unittest, Error, captured_output from test.support import TESTFN, unlink import traceback @@ -29,10 +29,6 @@ class SyntaxTracebackCases(unittest.TestCase): def syntax_error_with_caret_2(self): compile("1 +\n", "?", "exec") - def syntax_error_without_caret(self): - # XXX why doesn't compile raise the same traceback? - import test.badsyntax_nocaret - def syntax_error_bad_indentation(self): compile("def spam():\n print(1)\n print(2)", "?", "exec") @@ -51,13 +47,10 @@ class SyntaxTracebackCases(unittest.TestCase): self.assertTrue(err[1].find("+") == err[2].find("^")) # in the right place def test_nocaret(self): - if is_jython: - # jython adds a caret in this case (why shouldn't it?) - return - err = self.get_exception_format(self.syntax_error_without_caret, - SyntaxError) + exc = SyntaxError("error", ("x.py", 23, None, "bad syntax")) + err = traceback.format_exception_only(SyntaxError, exc) self.assertEqual(len(err), 3) - self.assertTrue(err[1].strip() == "[x for x in x] = x") + self.assertEqual(err[1].strip(), "bad syntax") def test_bad_indentation(self): err = self.get_exception_format(self.syntax_error_bad_indentation, |