Skip to content

gh-119205: Fix autocompletion bug in new repl #119229

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 15 commits into from
May 21, 2024
Merged
Prev Previous commit
Next Next commit
gh-119205: revert unnecessary changes
  • Loading branch information
koxudaxi committed May 20, 2024
commit 241e6345684caa05a3136d6160f29e67d0466b32
29 changes: 15 additions & 14 deletions Lib/test/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
readline = import_module("readline")

from _pyrepl.console import Console, Event
from _pyrepl.readline import ReadlineAlikeReader, ReadlineConfig, _ReadlineWrapper
from _pyrepl.readline import ReadlineAlikeReader, ReadlineConfig
from _pyrepl.simple_interact import _strip_final_indent
from _pyrepl.unix_eventqueue import EventQueue
from _pyrepl.input import KeymapTranslator
Expand Down Expand Up @@ -279,7 +279,7 @@ def test_cursor_position_double_width_characters_move_up(self):

# fmt: off
code = (
f"{for_loop}\n"
f"{for_loop}\n"
" ' 可口可乐; 可口可樂'"
)
# fmt: on
Expand All @@ -302,7 +302,7 @@ def test_cursor_position_double_width_characters_move_up_down(self):

# fmt: off
code = (
f"{for_loop}\n"
f"{for_loop}\n"
" ' 可口可乐; 可口可樂'"
)
# fmt: on
Expand Down Expand Up @@ -349,8 +349,8 @@ def test_cursor_position_move_up_to_eol(self):
code = (
f"{first_line}\n"
f"{second_line}\n"
" h\n"
" hel"
" h\n"
" hel"
)
# fmt: on

Expand Down Expand Up @@ -382,7 +382,7 @@ def test_cursor_position_move_down_to_eol(self):
"for _ in _:\n"
" hello\n"
" h\n"
f"{last_line}"
f"{last_line}"
)
# fmt: on

Expand Down Expand Up @@ -655,6 +655,7 @@ def test_func(self):
self.assertEqual(output[0], "dummy.test_func.")
self.assertEqual(f.getvalue(), "")


@patch("_pyrepl.curses.tigetstr", lambda x: b"")
class TestUnivEventQueue(TestCase):
def setUp(self):
Expand Down Expand Up @@ -930,24 +931,24 @@ def assert_screen_equals(self, reader, expected):
def test_calc_screen_wrap_simple(self):
events = code_to_events(10 * "a")
reader, _ = handle_events_narrow_console(events)
self.assert_screen_equals(reader, f"{9 * "a"}\\\na")
self.assert_screen_equals(reader, f"{9*"a"}\\\na")

def test_calc_screen_wrap_wide_characters(self):
events = code_to_events(8 * "a" + "樂")
reader, _ = handle_events_narrow_console(events)
self.assert_screen_equals(reader, f"{8 * "a"}\\\n樂")
self.assert_screen_equals(reader, f"{8*"a"}\\\n樂")

def test_calc_screen_wrap_three_lines(self):
events = code_to_events(20 * "a")
reader, _ = handle_events_narrow_console(events)
self.assert_screen_equals(reader, f"{9 * "a"}\\\n{9 * "a"}\\\naa")
self.assert_screen_equals(reader, f"{9*"a"}\\\n{9*"a"}\\\naa")

def test_calc_screen_wrap_three_lines_mixed_character(self):
# fmt: off
code = (
"def f():\n"
f" {8 * "a"}\n"
f" {5 * "樂"}"
f" {8*"a"}\n"
f" {5*"樂"}"
)
# fmt: on

Expand All @@ -957,9 +958,9 @@ def test_calc_screen_wrap_three_lines_mixed_character(self):
# fmt: off
self.assert_screen_equals(reader, (
"def f():\n"
f" {7 * "a"}\\\n"
f" {7*"a"}\\\n"
"a\n"
f" {3 * "樂"}\\\n"
f" {3*"樂"}\\\n"
"樂樂"
))
# fmt: on
Expand Down Expand Up @@ -992,7 +993,7 @@ def test_calc_screen_backspace_in_second_line_after_wrap(self):
],
)
reader, _ = handle_events_narrow_console(events)
self.assert_screen_equals(reader, f"{9 * "a"}\\\na")
self.assert_screen_equals(reader, f"{9*"a"}\\\na")

def test_setpos_for_xy_simple(self):
events = code_to_events("11+11")
Expand Down
Loading