Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 62943a7

Browse files
committed
Make the test work with actual buffer
1 parent 0eac64c commit 62943a7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

tests/test_shortcuts.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from IPython.terminal.interactiveshell import PtkHistoryAdapter
23
from IPython.terminal.shortcuts.auto_suggest import (
34
accept,
45
accept_or_jump_to_end,
@@ -39,7 +40,7 @@ def make_event(text, cursor, suggestion):
3940
try:
4041
from .fake_llm import FIBONACCI
4142
except ImportError:
42-
FIBONACCI = None
43+
FIBONACCI = ''
4344

4445

4546
@dec.skip_without("jupyter_ai")
@@ -49,9 +50,13 @@ async def test_llm_autosuggestion():
4950
ip = get_ipython()
5051
ip.auto_suggest = provider
5152
ip.llm_provider_class = "tests.fake_llm.FibonacciCompletionProvider"
53+
ip.history_manager.get_range = Mock(return_value=[])
5254
text = "def fib"
53-
event = make_event(text, len(text), "")
54-
event.current_buffer.history.shell.history_manager.get_range = Mock(return_value=[])
55+
event = Mock()
56+
event.current_buffer = Buffer(
57+
history=PtkHistoryAdapter(ip),
58+
)
59+
event.current_buffer.insert_text(text, move_cursor=True)
5560
await llm_autosuggestion(event)
5661
assert event.current_buffer.suggestion.text == FIBONACCI[len(text) :]
5762

0 commit comments

Comments
 (0)