MCPcopy Create free account
hub / github.com/ipython/ipython / test_greedy_completions

Method test_greedy_completions

IPython/core/tests/test_completer.py:461–497  ·  view source on GitHub ↗

Test the capability of the Greedy completer. Most of the test here does not really show off the greedy completer, for proof each of the text below now pass with Jedi. The greedy completer is capable of more. See the :any:`test_dict_key_completion_contexts`

(self)

Source from the content-addressed store, hash-verified

459 assert l[0].text == "zoo" # and not `it.accumulate`
460
461 def test_greedy_completions(self):
462 """
463 Test the capability of the Greedy completer.
464
465 Most of the test here does not really show off the greedy completer, for proof
466 each of the text below now pass with Jedi. The greedy completer is capable of more.
467
468 See the :any:`test_dict_key_completion_contexts`
469
470 """
471 ip = get_ipython()
472 ip.ex("a=list(range(5))")
473 _, c = ip.complete(".", line="a[0].")
474 nt.assert_false(".real" in c, "Shouldn't have completed on a[0]: %s" % c)
475
476 def _(line, cursor_pos, expect, message, completion):
477 with greedy_completion(), provisionalcompleter():
478 ip.Completer.use_jedi = False
479 _, c = ip.complete(".", line=line, cursor_pos=cursor_pos)
480 nt.assert_in(expect, c, message % c)
481
482 ip.Completer.use_jedi = True
483 with provisionalcompleter():
484 completions = ip.Completer.completions(line, cursor_pos)
485 nt.assert_in(completion, completions)
486
487 with provisionalcompleter():
488 yield _, "a[0].", 5, "a[0].real", "Should have completed on a[0].: %s", Completion(
489 5, 5, "real"
490 )
491 yield _, "a[0].r", 6, "a[0].real", "Should have completed on a[0].r: %s", Completion(
492 5, 6, "real"
493 )
494
495 yield _, "a[0].from_", 10, "a[0].from_bytes", "Should have completed on a[0].from_: %s", Completion(
496 5, 10, "from_bytes"
497 )
498
499 def test_omit__names(self):
500 # also happens to test IPCompleter as a configurable

Callers

nothing calls this directly

Calls 5

get_ipythonFunction · 0.90
provisionalcompleterFunction · 0.90
CompletionClass · 0.90
exMethod · 0.80
completeMethod · 0.45

Tested by

no test coverage detected