[Python-checkins] Add additional test for multi-line SyntaxError (GH-15003)

Pablo Galindo webhook-mailer at python.org
Mon Jul 29 11:06:25 EDT 2019


https://github.com/python/cpython/commit/44212ec8111febfe5fc6c6ed231d4ef2d98bd7e2
commit: 44212ec8111febfe5fc6c6ed231d4ef2d98bd7e2
branch: master
author: Anthony Sottile <asottile at umich.edu>
committer: Pablo Galindo <Pablogsal at gmail.com>
date: 2019-07-29T16:05:55+01:00
summary:

Add additional test for multi-line SyntaxError (GH-15003)

files:
M Lib/test/test_cmd_line_script.py

diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index 633e0fd746f5..80198f81a1c5 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -627,6 +627,22 @@ def test_syntaxerror_multi_line_fstring(self):
                 ],
             )
 
+    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:



More information about the Python-checkins mailing list