mirror of
https://github.com/python/cpython.git
synced 2025-10-27 11:44:39 +00:00
gh-135621: Remove dependency on curses from PyREPL (GH-136758)
This commit is contained in:
parent
d1d526afe7
commit
09dfb50f1b
11 changed files with 1229 additions and 160 deletions
|
|
@ -3,6 +3,8 @@
|
|||
from unittest.mock import patch
|
||||
from test import support
|
||||
|
||||
from _pyrepl import terminfo
|
||||
|
||||
try:
|
||||
from _pyrepl.console import Event
|
||||
from _pyrepl import base_eventqueue
|
||||
|
|
@ -172,17 +174,22 @@ def _push(keys):
|
|||
self.assertEqual(eq.get(), _event("key", "a"))
|
||||
|
||||
|
||||
class EmptyTermInfo(terminfo.TermInfo):
|
||||
def get(self, cap: str) -> bytes:
|
||||
return b""
|
||||
|
||||
|
||||
@unittest.skipIf(support.MS_WINDOWS, "No Unix event queue on Windows")
|
||||
class TestUnixEventQueue(EventQueueTestBase, unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.enterContext(patch("_pyrepl.curses.tigetstr", lambda x: b""))
|
||||
self.file = tempfile.TemporaryFile()
|
||||
|
||||
def tearDown(self) -> None:
|
||||
self.file.close()
|
||||
|
||||
def make_eventqueue(self) -> base_eventqueue.BaseEventQueue:
|
||||
return unix_eventqueue.EventQueue(self.file.fileno(), "utf-8")
|
||||
ti = EmptyTermInfo("ansi")
|
||||
return unix_eventqueue.EventQueue(self.file.fileno(), "utf-8", ti)
|
||||
|
||||
|
||||
@unittest.skipUnless(support.MS_WINDOWS, "No Windows event queue on Unix")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue