]> granicus.if.org Git - python/commitdiff
Add test for #3684.
authorGeorg Brandl <georg@python.org>
Thu, 4 Jun 2009 18:59:58 +0000 (18:59 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 4 Jun 2009 18:59:58 +0000 (18:59 +0000)
Lib/test/test_traceback.py

index 5cd08eeff3ded5fe0f9c2224f0fb59eda2e77767..1140a942b9d9522f6bf31eb5b644bf4506c4ffac 100644 (file)
@@ -24,6 +24,9 @@ class TracebackCases(unittest.TestCase):
     def syntax_error_with_caret(self):
         compile("def fact(x):\n\treturn x!\n", "?", "exec")
 
+    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
@@ -39,6 +42,12 @@ class TracebackCases(unittest.TestCase):
         self.assert_("^" in err[2]) # third line has caret
         self.assert_(err[1].find("!") == err[2].find("^")) # in the right place
 
+        err = self.get_exception_format(self.syntax_error_with_caret_2,
+                                        SyntaxError)
+        self.assert_("^" in err[2]) # third line has caret
+        self.assert_(err[2].count('\n') == 1) # and no additional newline
+        self.assert_(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?)