summaryrefslogtreecommitdiff
path: root/Lib/test/test_repl.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-01-06 15:59:09 +0000
committerGitHub <noreply@github.com>2020-01-06 15:59:09 +0000
commit5ec91f78d59d9c39b984f284e00cd04b96ddb5db (patch)
tree3584ef9005da8bc532c12665147c8313142ff0e6 /Lib/test/test_repl.py
parent075ebad369d94342624792a41d3055c907bfa436 (diff)
downloadcpython-git-5ec91f78d59d9c39b984f284e00cd04b96ddb5db.tar.gz
bpo-39209: Manage correctly multi-line tokens in interactive mode (GH-17860)
Diffstat (limited to 'Lib/test/test_repl.py')
-rw-r--r--Lib/test/test_repl.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_repl.py b/Lib/test/test_repl.py
index 9efd459a6f..71f192f90d 100644
--- a/Lib/test/test_repl.py
+++ b/Lib/test/test_repl.py
@@ -58,5 +58,41 @@ class TestInteractiveInterpreter(unittest.TestCase):
# Exit code 120: Py_FinalizeEx() failed to flush stdout and stderr.
self.assertIn(p.returncode, (1, 120))
+ @cpython_only
+ def test_multiline_string_parsing(self):
+ # bpo-39209: Multiline string tokens need to be handled in the tokenizer
+ # in two places: the interactive path and the non-interactive path.
+ user_input = '''\
+ x = """<?xml version="1.0" encoding="iso-8859-1"?>
+ <test>
+ <Users>
+ <fun25>
+ <limits>
+ <total>0KiB</total>
+ <kbps>0</kbps>
+ <rps>1.3</rps>
+ <connections>0</connections>
+ </limits>
+ <usages>
+ <total>16738211KiB</total>
+ <kbps>237.15</kbps>
+ <rps>1.3</rps>
+ <connections>0</connections>
+ </usages>
+ <time_to_refresh>never</time_to_refresh>
+ <limit_exceeded_URL>none</limit_exceeded_URL>
+ </fun25>
+ </Users>
+ </test>"""
+ '''
+ user_input = dedent(user_input)
+ user_input = user_input.encode()
+ p = spawn_repl()
+ with SuppressCrashReport():
+ p.stdin.write(user_input)
+ output = kill_python(p)
+ self.assertEqual(p.returncode, 0)
+
+
if __name__ == "__main__":
unittest.main()