Skip to content

Commit bf0b8a6

Browse files
Add additional test for multi-line SyntaxError (GH-15003)
(cherry picked from commit 44212ec) Co-authored-by: Anthony Sottile <[email protected]>
1 parent 9ea738e commit bf0b8a6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/test/test_cmd_line_script.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,22 @@ def test_syntaxerror_multi_line_fstring(self):
615615
],
616616
)
617617

618+
def test_syntaxerror_invalid_escape_sequence_multi_line(self):
619+
script = 'foo = """\\q\n"""\n'
620+
with support.temp_dir() as script_dir:
621+
script_name = _make_test_script(script_dir, 'script', script)
622+
exitcode, stdout, stderr = assert_python_failure(
623+
'-Werror', script_name,
624+
)
625+
self.assertEqual(
626+
stderr.splitlines()[-3:],
627+
[
628+
b' foo = """\\q',
629+
b' ^',
630+
b'SyntaxError: invalid escape sequence \\q',
631+
],
632+
)
633+
618634
def test_consistent_sys_path_for_direct_execution(self):
619635
# This test case ensures that the following all give the same
620636
# sys.path configuration:

0 commit comments

Comments
 (0)