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)
| 594 | reason="Parso does not yet parse 3.13", |
| 595 | ) |
| 596 | def test_greedy_completions(self): |
| 597 | """ |
| 598 | Test the capability of the Greedy completer. |
| 599 | |
| 600 | Most of the test here does not really show off the greedy completer, for proof |
| 601 | each of the text below now pass with Jedi. The greedy completer is capable of more. |
| 602 | |
| 603 | See the :any:`test_dict_key_completion_contexts` |
| 604 | |
| 605 | """ |
| 606 | ip = get_ipython() |
| 607 | ip.ex("a=list(range(5))") |
| 608 | ip.ex("b,c = 1, 1.2") |
| 609 | ip.ex("d = {'a b': str}") |
| 610 | ip.ex("x=y='a'") |
| 611 | _, c = ip.complete(".", line="a[0].") |
| 612 | self.assertFalse(".real" in c, "Shouldn't have completed on a[0]: %s" % c) |
| 613 | |
| 614 | def _(line, cursor_pos, expect, message, completion): |
| 615 | with greedy_completion(), provisionalcompleter(): |
| 616 | ip.Completer.use_jedi = False |
| 617 | _, c = ip.complete(".", line=line, cursor_pos=cursor_pos) |
| 618 | self.assertIn(expect, c, message % c) |
| 619 | |
| 620 | ip.Completer.use_jedi = True |
| 621 | with provisionalcompleter(): |
| 622 | completions = ip.Completer.completions(line, cursor_pos) |
| 623 | self.assertIn(completion, list(completions)) |
| 624 | |
| 625 | with provisionalcompleter(): |
| 626 | _( |
| 627 | "a[0].", |
| 628 | 5, |
| 629 | ".real", |
| 630 | "Should have completed on a[0].: %s", |
| 631 | Completion(5, 5, "real"), |
| 632 | ) |
| 633 | _( |
| 634 | "a[0].r", |
| 635 | 6, |
| 636 | ".real", |
| 637 | "Should have completed on a[0].r: %s", |
| 638 | Completion(5, 6, "real"), |
| 639 | ) |
| 640 | _( |
| 641 | "a[0].from_", |
| 642 | 10, |
| 643 | ".from_bytes", |
| 644 | "Should have completed on a[0].from_: %s", |
| 645 | Completion(5, 10, "from_bytes"), |
| 646 | ) |
| 647 | _( |
| 648 | "assert str.star", |
| 649 | 14, |
| 650 | ".startswith", |
| 651 | "Should have completed on `assert str.star`: %s", |
| 652 | Completion(11, 14, "startswith"), |
| 653 | ) |
nothing calls this directly
no test coverage detected