summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2024-05-07 12:54:56 (GMT)
committerGitHub <noreply@github.com>2024-05-07 12:54:56 (GMT)
commit7d90b8aadbd6993ee50a73b7536f769334718423 (patch)
treec52e6f2f5f03a3e2a6b4f57a5b2a0e321c72000a /Lib/test
parentad3d877a126bc892d1c598cf1357a2c39fd466c7 (diff)
downloadcpython-7d90b8aadbd6993ee50a73b7536f769334718423.zip
cpython-7d90b8aadbd6993ee50a73b7536f769334718423.tar.gz
cpython-7d90b8aadbd6993ee50a73b7536f769334718423.tar.bz2
gh-111201: Allow bracketed paste to work (GH-118700)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_pyrepl.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl.py b/Lib/test/test_pyrepl.py
index 3df76e0..b7ae91b 100644
--- a/Lib/test/test_pyrepl.py
+++ b/Lib/test/test_pyrepl.py
@@ -817,6 +817,46 @@ class TestPasteEvent(TestCase):
output = multiline_input(reader)
self.assertEqual(output, output_code)
+ def test_bracketed_paste(self):
+ """Test that bracketed paste using \x1b[200~ and \x1b[201~ works."""
+ # fmt: off
+ input_code = (
+ 'def a():\n'
+ ' for x in range(10):\n'
+ '\n'
+ ' if x%2:\n'
+ ' print(x)\n'
+ '\n'
+ ' else:\n'
+ ' pass\n'
+ )
+ # fmt: on
+
+ output_code = (
+ 'def a():\n'
+ ' for x in range(10):\n'
+ '\n'
+ ' if x%2:\n'
+ ' print(x)\n'
+ '\n'
+ ' else:\n'
+ ' pass\n'
+ '\n'
+ )
+
+ paste_start = "\x1b[200~"
+ paste_end = "\x1b[201~"
+
+ events = itertools.chain(
+ code_to_events(paste_start),
+ code_to_events(input_code),
+ code_to_events(paste_end),
+ code_to_events("\n"),
+ )
+ reader = self.prepare_reader(events)
+ output = multiline_input(reader)
+ self.assertEqual(output, output_code)
+
class TestReader(TestCase):
def assert_screen_equals(self, reader, expected):