Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-111201: Allow pasted code to contain multiple statements in the REPL #118712

Merged
merged 8 commits into from
May 7, 2024
Prev Previous commit
Add test for single line bracketed paste
  • Loading branch information
lysnikolaou committed May 7, 2024
commit 7331e9b688849cff6f87da4a7da8919a75e5212c
19 changes: 17 additions & 2 deletions Lib/test/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,6 @@ def test_bracketed_paste(self):
' else:\n'
' pass\n'
)
# fmt: on

output_code = (
'def a():\n'
Expand All @@ -842,8 +841,8 @@ def test_bracketed_paste(self):
'\n'
' else:\n'
' pass\n'
'\n'
)
# fmt: on

paste_start = "\x1b[200~"
paste_end = "\x1b[201~"
Expand All @@ -858,6 +857,22 @@ def test_bracketed_paste(self):
output = multiline_input(reader)
self.assertEqual(output, output_code)

def test_bracketed_paste_single_line(self):
input_code = "oneline"

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, input_code)


class TestReader(TestCase):
def assert_screen_equals(self, reader, expected):
Expand Down
Loading