]> granicus.if.org Git - python/commitdiff
Add additional test for multi-line SyntaxError (GH-15003)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 29 Jul 2019 15:26:29 +0000 (08:26 -0700)
committerGitHub <noreply@github.com>
Mon, 29 Jul 2019 15:26:29 +0000 (08:26 -0700)
(cherry picked from commit 44212ec8111febfe5fc6c6ed231d4ef2d98bd7e2)

Co-authored-by: Anthony Sottile <asottile@umich.edu>
Lib/test/test_cmd_line_script.py

index 4cc265e60b669b17054e064b9730d860a90ee2b7..b74eeba81e048a2e9633eb43b35bdc9327d8dbc6 100644 (file)
@@ -615,6 +615,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: