gh-135621: Remove dependency on curses from PyREPL (GH-136758)

This commit is contained in:
Łukasz Langa 2025-07-21 11:57:34 +02:00 committed by GitHub
parent d1d526afe7
commit 09dfb50f1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1229 additions and 160 deletions

View file

@ -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")