8000 Mock getheightwidth · python/cpython@561ac47 · GitHub
[go: up one dir, main page]

Skip to content

Commit 561ac47

Browse files
committed
Mock getheightwidth
1 parent e84f943 commit 561ac47

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Lib/test/test_pyrepl.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def handle_all_events(
104104

105105

106106
handle_events_narrow_console = partial(
107-
handle_all_events, prepare_console=partial(prepare_mock_console, width=10)
107+
handle_all_events,
108+
prepare_console=partial(prepare_mock_console, width=10),
108109
)
109110

110111

@@ -936,21 +937,31 @@ def test_setpos_fromxy_in_wrapped_line(self):
936937
def unix_console(events, **kwargs):
937938
console = UnixConsole()
938939
console.get_event = MagicMock(side_effect=events)
940+
941+
height = kwargs.get("height", 25)
942+
width = kwargs.get("width", 80)
943+
console.getheightwidth = MagicMock(side_effect=lambda: (height, width))
944+
939945
console.prepare()
940946
for key, val in kwargs.items():
941947
setattr(console, key, val)
942948
return console
943949

944950

945-
handle_events_unix_console = partial(handle_all_events, prepare_console=unix_console)
951+
handle_events_unix_console = partial(
952+
handle_all_events,
953+
prepare_console=partial(unix_console),
954+
)
946955
handle_events_narrow_unix_console = partial(
947-
handle_all_events, prepare_console=partial(unix_console, width=5)
956+
handle_all_events,
957+
prepare_console=partial(unix_console, width=5),
948958
)
949959
handle_events_short_unix_console = partial(
950-
handle_all_events, prepare_console=partial(unix_console, height=1)
960+
handle_all_events,
961+
prepare_console=partial(unix_console, height=1),
951962
)
952963
handle_events_unix_console_height_3 = partial(
953-
handle_all_events, prepare_console=partial(unix_console, height=2)
964+
handle_all_events, prepare_console=partial(unix_console, height=3)
954965
)
955966

956967

@@ -1152,6 +1163,7 @@ def test_resize_bigger_on_multiline_function(self, _os_write):
11521163
reader, console = handle_events_short_unix_console(events)
11531164

11541165
console.height = 2
1166+
console.getheightwidth = MagicMock(lambda _: (2, 80))
11551167

11561168
def same_reader(_):
11571169
return reader
@@ -1185,6 +1197,7 @@ def test_resize_smaller_on_multiline_function(self, _os_write):
11851197
reader, console = handle_events_unix_console_height_3(events)
11861198

11871199
console.height = 1
1200+
console.getheightwidth = MagicMock(lambda _: (1, 80))
11881201

11891202
def same_reader(_):
11901203
return reader

0 commit comments

Comments
 (0)
0