8000 gh-111201: Add tests for unix console class in pyrepl by lysnikolaou · Pull Request #118653 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-111201: Add tests for unix console class in pyrepl #118653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 20, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mock getheightwidth
  • Loading branch information
lysnikolaou committed May 7, 2024
commit 561ac47f22fcc7c383d6de29f9a7196ceb8cf135
23 changes: 18 additions & 5 deletions Lib/test/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def handle_all_events(


handle_events_narrow_console = partial(
handle_all_events, prepare_console=partial(prepare_mock_console, width=10)
handle_all_events,
prepare_console=partial(prepare_mock_console, width=10),
)


Expand Down Expand Up @@ -936,21 +937,31 @@ def test_setpos_fromxy_in_wrapped_line(self):
def unix_console(events, **kwargs):
console = UnixConsole()
console.get_event = MagicMock(side_effect=events)

height = kwargs.get("height", 25)
width = kwargs.get("width", 80)
console.getheightwidth = MagicMock(side_effect=lambda: (height, width))

console.prepare()
for key, val in kwargs.items():
setattr(console, key, val)
return console


handle_events_unix_console = partial(handle_all_events, prepare_console=unix_console)
handle_events_unix_console = partial(
handle_all_events,
prepare_console=partial(unix_console),
)
handle_events_narrow_unix_console = partial(
handle_all_events, prepare_console=partial(unix_console, width=5)
handle_all_events,
prepare_console=partial(unix_console, width=5),
)
handle_events_short_unix_console = partial(
handle_all_events, prepare_console=partial(unix_console, height=1)
handle_all_events,
prepare_console=partial(unix_console, height=1),
)
handle_events_unix_console_height_3 = partial(
handle_all_events, prepare_console=partial(unix_console, height=2)
handle_all_events, prepare_console=partial(unix_console, height=3)
)


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

console.height = 2
console.getheightwidth = MagicMock(lambda _: (2, 80))

def same_reader(_):
return reader
Expand Down Expand Up @@ -1185,6 +1197,7 @@ def test_resize_smaller_on_multiline_function(self, _os_write):
reader, console = handle_events_unix_console_height_3(events)

console.height = 1
console.getheightwidth = MagicMock(lambda _: (1, 80))

def same_reader(_):
return reader
Expand Down
0