55import sys
66import unittest
77import re
8- from test .support import run_unittest , is_jython , Error , captured_output
8+ from test .support import run_unittest , Error , captured_output
99from test .support import TESTFN , unlink
1010
1111import traceback
@@ -29,10 +29,6 @@ def syntax_error_with_caret(self):
2929 def syntax_error_with_caret_2 (self ):
3030 compile ("1 +\n " , "?" , "exec" )
3131
32- def syntax_error_without_caret (self ):
33- # XXX why doesn't compile raise the same traceback?
34- import test .badsyntax_nocaret
35-
3632 def syntax_error_bad_indentation (self ):
3733 compile ("def spam():\n print(1)\n print(2)" , "?" , "exec" )
3834
@@ -51,13 +47,10 @@ def test_caret(self):
5147 self .assertTrue (err [1 ].find ("+" ) == err [2 ].find ("^" )) # in the right place
5248
5349 def test_nocaret (self ):
54- if is_jython :
55- # jython adds a caret in this case (why shouldn't it?)
56- return
57- err = self .get_exception_format (self .syntax_error_without_caret ,
58- SyntaxError )
50+ exc = SyntaxError ("error" , ("x.py" , 23 , None , "bad syntax" ))
51+ err = traceback .format_exception_only (SyntaxError , exc )
5952 self .assertEqual (len (err ), 3 )
60- self .assertTrue (err [1 ].strip () == "[x for x in x] = x " )
53+ self .assertEqual (err [1 ].strip (), "bad syntax " )
6154
6255 def test_bad_indentation (self ):
6356 err = self .get_exception_format (self .syntax_error_bad_indentation ,
0 commit comments