gh-133346: Make theming support in _colorize extensible (GH-133347)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Łukasz Langa 2025-05-05 23:45:25 +02:00 committed by GitHub
parent 9cc77aaf9d
commit f610bbdf74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 585 additions and 371 deletions

View file

@ -3,11 +3,12 @@
import sys
import unittest
from functools import partial
from test.support import os_helper
from test.support import os_helper, force_not_colorized_test_class
from unittest import TestCase
from unittest.mock import MagicMock, call, patch, ANY
from .support import handle_all_events, code_to_events, reader_no_colors
from .support import handle_all_events, code_to_events
try:
from _pyrepl.console import Event
@ -33,12 +34,10 @@ def unix_console(events, **kwargs):
handle_events_unix_console = partial(
handle_all_events,
prepare_reader=reader_no_colors,
prepare_console=unix_console,
)
handle_events_narrow_unix_console = partial(
handle_all_events,
prepare_reader=reader_no_colors,
prepare_console=partial(unix_console, width=5),
)
handle_events_short_unix_console = partial(
@ -120,6 +119,7 @@ def unix_console(events, **kwargs):
)
@patch("termios.tcsetattr", lambda a, b, c: None)
@patch("os.write")
@force_not_colorized_test_class
class TestConsole(TestCase):
def test_simple_addition(self, _os_write):
code = "12+34"
@ -255,9 +255,7 @@ def test_resize_bigger_on_multiline_function(self, _os_write):
# fmt: on
events = itertools.chain(code_to_events(code))
reader, console = handle_events_short_unix_console(
events, prepare_reader=reader_no_colors
)
reader, console = handle_events_short_unix_console(events)
console.height = 2
console.getheightwidth = MagicMock(lambda _: (2, 80))