mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-119842: Honor PyOS_InputHook in the new REPL (GH-119843)
Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Michael Droettboom <mdboom@gmail.com>
This commit is contained in:
parent
bf5e1065f4
commit
d9095194dd
8 changed files with 144 additions and 11 deletions
|
@ -2,8 +2,10 @@ import itertools
|
|||
import functools
|
||||
import rlcompleter
|
||||
from unittest import TestCase
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from .support import handle_all_events, handle_events_narrow_console, code_to_events, prepare_reader
|
||||
from test.support import import_helper
|
||||
from _pyrepl.console import Event
|
||||
from _pyrepl.reader import Reader
|
||||
|
||||
|
@ -179,6 +181,21 @@ class TestReader(TestCase):
|
|||
self.assert_screen_equals(reader, expected)
|
||||
self.assertTrue(reader.finished)
|
||||
|
||||
def test_input_hook_is_called_if_set(self):
|
||||
input_hook = MagicMock()
|
||||
def _prepare_console(events):
|
||||
console = MagicMock()
|
||||
console.get_event.side_effect = events
|
||||
console.height = 100
|
||||
console.width = 80
|
||||
console.input_hook = input_hook
|
||||
return console
|
||||
|
||||
events = code_to_events("a")
|
||||
reader, _ = handle_all_events(events, prepare_console=_prepare_console)
|
||||
|
||||
self.assertEqual(len(input_hook.mock_calls), 4)
|
||||
|
||||
def test_keyboard_interrupt_clears_screen(self):
|
||||
namespace = {"itertools": itertools}
|
||||
code = "import itertools\nitertools."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue