MCPcopy Index your code
hub / github.com/python/cpython / test_bracketed_paste

Method test_bracketed_paste

Lib/test/test_pyrepl/test_pyrepl.py:1807–1844  ·  view source on GitHub ↗

Test that bracketed paste using \x1b[200~ and \x1b[201~ works.

(self)

Source from the content-addressed store, hash-verified

1805 self.assertEqual(output, output_code)
1806
1807 def test_bracketed_paste(self):
1808 """Test that bracketed paste using \x1b[200~ and \x1b[201~ works."""
1809 # fmt: off
1810 input_code = (
1811 "def a():\n"
1812 " for x in range(10):\n"
1813 "\n"
1814 " if x%2:\n"
1815 " print(x)\n"
1816 "\n"
1817 " else:\n"
1818 " pass\n"
1819 )
1820
1821 output_code = (
1822 "def a():\n"
1823 " for x in range(10):\n"
1824 "\n"
1825 " if x%2:\n"
1826 " print(x)\n"
1827 "\n"
1828 " else:\n"
1829 " pass\n"
1830 )
1831 # fmt: on
1832
1833 paste_start = "\x1b[200~"
1834 paste_end = "\x1b[201~"
1835
1836 events = itertools.chain(
1837 code_to_events(paste_start),
1838 code_to_events(input_code),
1839 code_to_events(paste_end),
1840 code_to_events("\n"),
1841 )
1842 reader = self.prepare_reader(events)
1843 output = multiline_input(reader)
1844 self.assertEqual(output, output_code)
1845
1846 def test_bracketed_paste_single_line(self):
1847 input_code = "oneline"

Callers

nothing calls this directly

Calls 5

prepare_readerMethod · 0.95
code_to_eventsFunction · 0.85
multiline_inputFunction · 0.85
chainMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected