]> granicus.if.org Git - python/commitdiff
Add additional test for multi-line SyntaxError (GH-15003)
authorAnthony Sottile <asottile@umich.edu>
Mon, 29 Jul 2019 15:05:55 +0000 (08:05 -0700)
committerPablo Galindo <Pablogsal@gmail.com>
Mon, 29 Jul 2019 15:05:55 +0000 (16:05 +0100)
Lib/test/test_cmd_line_script.py

index 633e0fd746f5edb515efb102a7aa608e5588e423..80198f81a1c5072bb6fdbaecc72c3d9275a0784f 100644 (file)
@@ -627,6 +627,22 @@ class CmdLineTest(unittest.TestCase):
                 ],
             )
 
+    def test_syntaxerror_invalid_escape_sequence_multi_line(self):
+        script = 'foo = """\\q\n"""\n'
+        with support.temp_dir() as script_dir:
+            script_name = _make_test_script(script_dir, 'script', script)
+            exitcode, stdout, stderr = assert_python_failure(
+                '-Werror', script_name,
+            )
+            self.assertEqual(
+                stderr.splitlines()[-3:],
+                [
+                    b'    foo = """\\q',
+                    b'          ^',
+                    b'SyntaxError: invalid escape sequence \\q',
+                ],
+            )
+
     def test_consistent_sys_path_for_direct_execution(self):
         # This test case ensures that the following all give the same
         # sys.path configuration: