MCPcopy Index your code
hub / github.com/ipython/ipython / test_navigable_provider

Function test_navigable_provider

tests/test_shortcuts.py:263–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

261
262@pytest.mark.asyncio
263async def test_navigable_provider():
264 provider = NavigableAutoSuggestFromHistory()
265 history = InMemoryHistory(history_strings=["very_a", "very", "very_b", "very_c"])
266 buffer = Buffer(history=history)
267 ip = get_ipython()
268 ip.auto_suggest = provider
269
270 async for _ in history.load():
271 pass
272
273 buffer.cursor_position = 5
274 buffer.text = "very"
275
276 up = swap_autosuggestion_up
277 down = swap_autosuggestion_down
278
279 event = Mock()
280 event.current_buffer = buffer
281
282 def get_suggestion():
283 suggestion = provider.get_suggestion(buffer, buffer.document)
284 buffer.suggestion = suggestion
285 return suggestion
286
287 assert get_suggestion().text == "_c"
288
289 # should go up
290 up(event)
291 assert get_suggestion().text == "_b"
292
293 # should skip over 'very' which is identical to buffer content
294 up(event)
295 assert get_suggestion().text == "_a"
296
297 # should cycle back to beginning
298 up(event)
299 assert get_suggestion().text == "_c"
300
301 # should cycle back through end boundary
302 down(event)
303 assert get_suggestion().text == "_a"
304
305 down(event)
306 assert get_suggestion().text == "_b"
307
308 down(event)
309 assert get_suggestion().text == "_c"
310
311 down(event)
312 assert get_suggestion().text == "_a"
313
314
315@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 4

get_suggestionFunction · 0.85
loadMethod · 0.80
get_ipythonFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…