Esempio n. 1
0
def test_omit__names():
    # also happens to test IPCompleter as a configurable
    ip = get_ipython()
    ip._hidden_attr = 1
    ip._x = {}
    c = ip.Completer
    ip.ex('ip=get_ipython()')
    cfg = Config()
    cfg.IPCompleter.omit__names = 0
    c.update_config(cfg)
    with provisionalcompleter():
        s,matches = c.complete('ip.')
        completions = set(c.completions('ip.', 3))

        nt.assert_in('ip.__str__', matches)
        nt.assert_in(Completion(3, 3, '__str__'), completions)
        
        nt.assert_in('ip._hidden_attr', matches)
        nt.assert_in(Completion(3,3, "_hidden_attr"), completions)


    cfg = Config()
    cfg.IPCompleter.omit__names = 1
    c.update_config(cfg)
    with provisionalcompleter():
        s,matches = c.complete('ip.')
        completions = set(c.completions('ip.', 3))

        nt.assert_not_in('ip.__str__', matches)
        nt.assert_not_in(Completion(3,3,'__str__'), completions)

        # nt.assert_in('ip._hidden_attr', matches)
        nt.assert_in(Completion(3,3, "_hidden_attr"), completions)

    cfg = Config()
    cfg.IPCompleter.omit__names = 2
    c.update_config(cfg)
    with provisionalcompleter():
        s,matches = c.complete('ip.')
        completions = set(c.completions('ip.', 3))

        nt.assert_not_in('ip.__str__', matches)
        nt.assert_not_in(Completion(3,3,'__str__'), completions)

        nt.assert_not_in('ip._hidden_attr', matches)
        nt.assert_not_in(Completion(3,3, "_hidden_attr"), completions)

    with provisionalcompleter():
        s,matches = c.complete('ip._x.')
        completions = set(c.completions('ip._x.', 6))

        nt.assert_in('ip._x.keys', matches)
        nt.assert_in(Completion(6,6, "keys"), completions)

    del ip._hidden_attr
    del ip._x
Esempio n. 2
0
 def _test_complete(reason, s, comp, start=None, end=None):
     l = len(s)
     start = start if start is not None else l
     end = end if end is not None else l
     with provisionalcompleter():
         completions = set(ip.Completer.completions(s, l))
         assert_in(Completion(start, end, comp), completions, reason)
Esempio n. 3
0
 def _test_not_complete(reason, s, comp):
     l = len(s)
     with provisionalcompleter():
         ip.Completer.use_jedi = True
         completions = set(ip.Completer.completions(s, l))
         ip.Completer.use_jedi = False
         assert_not_in(Completion(l, l, comp), completions, reason)
Esempio n. 4
0
def test_greedy_completions():
    """
    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`

    """
    ip = get_ipython()
    ip.ex('a=list(range(5))')
    _,c = ip.complete('.',line='a[0].')
    nt.assert_false('.real' in c,
                    "Shouldn't have completed on a[0]: %s"%c)
    with greedy_completion(), provisionalcompleter():
        def _(line, cursor_pos, expect, message, completion):
            ip.Completer.use_jedi = False
            _,c = ip.complete('.', line=line, cursor_pos=cursor_pos)
            nt.assert_in(expect, c, message % c)

            ip.Completer.use_jedi = True
            with provisionalcompleter():
                completions = ip.Completer.completions(line, cursor_pos)
            nt.assert_in(completion, completions)

        yield _, 'a[0].', 5, 'a[0].real', "Should have completed on a[0].: %s", Completion(5,5, 'real')
        yield _, 'a[0].r', 6, 'a[0].real', "Should have completed on a[0].r: %s", Completion(5,6, 'real')

        if sys.version_info > (3, 4):
            yield _, 'a[0].from_', 10, 'a[0].from_bytes', "Should have completed on a[0].from_: %s", Completion(5, 10, 'from_bytes')
Esempio n. 5
0
        def _(line, cursor_pos, expect, message, completion):
            ip.Completer.use_jedi = False
            _,c = ip.complete('.', line=line, cursor_pos=cursor_pos)
            nt.assert_in(expect, c, message % c)

            ip.Completer.use_jedi = True
            with provisionalcompleter():
                completions = ip.Completer.completions(line, cursor_pos)
            nt.assert_in(completion, completions)
Esempio n. 6
0
    def test_tab_complete_warning(self, ip):
        # GH 16409
        pytest.importorskip('IPython', minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "import pandas as pd; df = pd.DataFrame()"
        ip.run_code(code)
        with tm.assert_produces_warning(None):
            with provisionalcompleter('ignore'):
                list(ip.Completer.completions('df.', 1))
Esempio n. 7
0
    def test_tab_complete_warning(self, ip):
        # https://github.com/pandas-dev/pandas/issues/16409
        pytest.importorskip('IPython', minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "import pandas as pd; df = pd.DataFrame()"
        ip.run_code(code)
        with tm.assert_produces_warning(None):
            with provisionalcompleter('ignore'):
                list(ip.Completer.completions('df.', 1))
Esempio n. 8
0
    def test_tab_complete_warning(self, ip):
        # GH 16409
        pytest.importorskip("IPython", minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "import pandas as pd; df = pd.DataFrame()"
        ip.run_code(code)
        with tm.assert_produces_warning(None):
            with provisionalcompleter("ignore"):
                list(ip.Completer.completions("df.", 1))
Esempio n. 9
0
    def test_tab_complete_warning(self, ip):
        # https://github.com/pandas-dev/pandas/issues/16409
        pytest.importorskip("IPython", minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "import pandas as pd; s = pd.Series()"
        ip.run_code(code)
        with tm.assert_produces_warning(None):
            with provisionalcompleter("ignore"):
                list(ip.Completer.completions("s.", 1))
Esempio n. 10
0
    def test_tab_complete_warning(self, ip):
        # https://github.com/pandas-dev/pandas/issues/16409
        pytest.importorskip('IPython', minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "import pandas as pd; s = pd.Series()"
        ip.run_code(code)
        with tm.assert_produces_warning(None):
            with provisionalcompleter('ignore'):
                list(ip.Completer.completions('s.', 1))
Esempio n. 11
0
def test_completion_have_signature():
    """
    Lets make sure jedi is capable of pulling out the signature of the function we are completing.
    """
    ip = get_ipython()
    with provisionalcompleter():
        completions = ip.Completer.completions('ope', 3)
        c = next(completions)  # should be `open`
    assert 'file' in c.signature, "Signature of function was not found by completer"
    assert 'encoding' in c.signature, "Signature of function was not found by completer"
Esempio n. 12
0
def test_completion_have_signature():
    """
    Lets make sure jedi is capable of pulling out the signature of the function we are completing.
    """
    ip = get_ipython()
    with provisionalcompleter():
        completions = ip.Completer.completions('ope', 3)
        c = next(completions)  # should be `open`
    assert 'file' in c.signature, "Signature of function was not found by completer"
    assert 'encoding' in c.signature, "Signature of function was not found by completer"
Esempio n. 13
0
def test_tab_complete_ipython6_warning(ip):
    from IPython.core.completer import provisionalcompleter
    code = dedent("""\
    import pandas.util.testing as tm
    s = tm.makeTimeSeries()
    rs = s.resample("D")
    """)
    ip.run_code(code)

    with tm.assert_produces_warning(None):
        with provisionalcompleter('ignore'):
            list(ip.Completer.completions('rs.', 1))
def test_tab_complete_ipython6_warning(ip):
    from IPython.core.completer import provisionalcompleter
    code = dedent("""\
    import pandas.util.testing as tm
    s = tm.makeTimeSeries()
    rs = s.resample("D")
    """)
    ip.run_code(code)

    with tm.assert_produces_warning(None):
        with provisionalcompleter('ignore'):
            list(ip.Completer.completions('rs.', 1))
    async def test_tab_complete_warning(self, ip):
        # https://github.com/pandas-dev/pandas/issues/16409
        pytest.importorskip("IPython", minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "import pandas as pd; c = Categorical([])"
        await ip.run_code(code)

        # GH 31324 newer jedi version raises Deprecation warning;
        #  appears resolved 2021-02-02
        with tm.assert_produces_warning(None):
            with provisionalcompleter("ignore"):
                list(ip.Completer.completions("c.", 1))
Esempio n. 16
0
def test_deduplicate_completions():
    """
    Test that completions are correctly deduplicated (even if ranges are not the same)
    """
    ip = get_ipython()
    ip.ex(textwrap.dedent('''
    class Z:
        zoo = 1
    '''))
    with provisionalcompleter():
        l = list(_deduplicate_completions('Z.z', ip.Completer.completions('Z.z', 3)))

    assert len(l) == 1, 'Completions (Z.z<tab>) correctly deduplicate: %s ' % l
    assert l[0].text == 'zoo'  # and not `it.accumulate`
Esempio n. 17
0
    def get_completions(self, document, complete_event):
        if not document.current_line.strip():
            return
        # Some bits of our completion system may print stuff (e.g. if a module
        # is imported). This context manager ensures that doesn't interfere with
        # the prompt.

        with self.patch_stdout(), provisionalcompleter():
            body = document.text
            cursor_row = document.cursor_position_row
            cursor_col = document.cursor_position_col
            cursor_position = document.cursor_position
            offset = cursor_to_position(body, cursor_row, cursor_col)
            yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
Esempio n. 18
0
def test_deduplicate_completions():
    """
    Test that completions are correctly deduplicated (even if ranges are not the same)
    """
    ip = get_ipython()
    ip.ex(textwrap.dedent('''
    class Z:
        zoo = 1
    '''))
    with provisionalcompleter():
        l = list(_deduplicate_completions('Z.z', ip.Completer.completions('Z.z', 3)))

    assert len(l) == 1, 'Completions (Z.z<tab>) correctly deduplicate: %s ' % l
    assert l[0].text == 'zoo'  # and not `it.accumulate`
Esempio n. 19
0
    def test_greedy_completions(self):
        """
        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`

        """
        ip = get_ipython()
        ip.ex("a=list(range(5))")
        _, c = ip.complete(".", line="a[0].")
        self.assertFalse(".real" in c,
                         "Shouldn't have completed on a[0]: %s" % c)

        def _(line, cursor_pos, expect, message, completion):
            with greedy_completion(), provisionalcompleter():
                ip.Completer.use_jedi = False
                _, c = ip.complete(".", line=line, cursor_pos=cursor_pos)
                self.assertIn(expect, c, message % c)

                ip.Completer.use_jedi = True
                with provisionalcompleter():
                    completions = ip.Completer.completions(line, cursor_pos)
                self.assertIn(completion, completions)

        with provisionalcompleter():
            _(
                "a[0].",
                5,
                "a[0].real",
                "Should have completed on a[0].: %s",
                Completion(5, 5, "real"),
            )
            _(
                "a[0].r",
                6,
                "a[0].real",
                "Should have completed on a[0].r: %s",
                Completion(5, 6, "real"),
            )

            _(
                "a[0].from_",
                10,
                "a[0].from_bytes",
                "Should have completed on a[0].from_: %s",
                Completion(5, 10, "from_bytes"),
            )
Esempio n. 20
0
    def get_completions(self, document, complete_event):
        if not document.current_line.strip():
            return
        # Some bits of our completion system may print stuff (e.g. if a module
        # is imported). This context manager ensures that doesn't interfere with
        # the prompt.

        with patch_stdout(), provisionalcompleter():
            body = document.text
            cursor_row = document.cursor_position_row
            cursor_col = document.cursor_position_col
            cursor_position = document.cursor_position
            offset = cursor_to_position(body, cursor_row, cursor_col)
            yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
Esempio n. 21
0
 def test_completion_have_signature(self):
     """
     Lets make sure jedi is capable of pulling out the signature of the function we are completing.
     """
     ip = get_ipython()
     with provisionalcompleter():
         ip.Completer.use_jedi = True
         completions = ip.Completer.completions("ope", 3)
         c = next(completions)  # should be `open`
         ip.Completer.use_jedi = False
     assert "file" in c.signature, "Signature of function was not found by completer"
     assert (
         "encoding" in c.signature
     ), "Signature of function was not found by completer"
    def _experimental_do_complete(self, code, cursor_pos):
        """
        Experimental completions from IPython, using livy completion.
        """

        code = code.strip()
        if cursor_pos is None:
            cursor_pos = len(code)

        matches = []
        with provisionalcompleter():
            session_name = self.spark_controller.generate_livy_session_name(id(self))

            endpoint = build_endpoint(self.session_language)
            session_info_list = self.spark_controller.get_all_sessions_endpoint(endpoint)
            session_id = None
            for session in session_info_list:
                if session.session_name == session_name:
                    session_id = session.id

            if session_id:
                # Only complete the cursor_line
                cursor_line, cursor_column = position_to_cursor(code, cursor_pos)
                lines = code.split("\n")
                completion_line = lines[cursor_line]
                before_lines = lines[:cursor_line]
                if len(lines) > 1 and cursor_line > 0:
                    real_cursor_pos = cursor_pos - len("\n".join(before_lines)) - 1
                else:
                    real_cursor_pos = cursor_pos

                http_client = self.spark_controller._http_client(endpoint)
                kind = conf.get_livy_kind(self.session_language)
                res_completions = http_client.post_completion(session_id, kind, completion_line, real_cursor_pos)
                matches = res_completions.get("candidates", [])

        if matches:
            s = self.__get_cursor_start(code, cursor_pos, matches[0])
        else:
            s = cursor_pos

        res = {
            'matches': matches,
            'cursor_end': cursor_pos,
            'cursor_start': s,
            'metadata': {},
            'status': 'ok'
        }
        return res
async def test_tab_complete_ipython6_warning(ip):
    from IPython.core.completer import provisionalcompleter

    code = dedent("""\
    import pandas._testing as tm
    s = tm.makeTimeSeries()
    rs = s.resample("D")
    """)
    await ip.run_code(code)

    # GH 31324 newer jedi version raises Deprecation warning;
    #  appears resolved 2021-02-02
    with tm.assert_produces_warning(None):
        with provisionalcompleter("ignore"):
            list(ip.Completer.completions("rs.", 1))
Esempio n. 24
0
 def test_all_completions_dups(self):
     """
     Make sure the output of `IPCompleter.all_completions` does not have
     duplicated prefixes.
     """
     ip = get_ipython()
     c = ip.Completer
     ip.ex("class TestClass():\n\ta=1\n\ta1=2")
     for jedi_status in [True, False]:
         with provisionalcompleter():
             ip.Completer.use_jedi = jedi_status
             matches = c.all_completions("TestCl")
             assert matches == ["TestClass"], (jedi_status, matches)
             matches = c.all_completions("TestClass.")
             assert len(matches) > 2, (jedi_status, matches)
             matches = c.all_completions("TestClass.a")
             assert matches == ['TestClass.a', 'TestClass.a1'], jedi_status
Esempio n. 25
0
    async def test_tab_complete_warning(self, ip, frame_or_series):
        # GH 16409
        pytest.importorskip("IPython", minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        if frame_or_series is DataFrame:
            code = "from pandas import DataFrame; obj = DataFrame()"
        else:
            code = "from pandas import Series; obj = Series(dtype=object)"

        await ip.run_code(code)

        # GH 31324 newer jedi version raises Deprecation warning;
        #  appears resolved 2021-02-02
        with tm.assert_produces_warning(None):
            with provisionalcompleter("ignore"):
                list(ip.Completer.completions("obj.", 1))
Esempio n. 26
0
    async def test_tab_complete_warning(self, ip):
        # https://github.com/pandas-dev/pandas/issues/16409
        pytest.importorskip("IPython", minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "import pandas as pd; c = Categorical([])"
        await ip.run_code(code)

        # GH 31324 newer jedi version raises Deprecation warning
        import jedi

        if jedi.__version__ < "0.16.0":
            warning = tm.assert_produces_warning(None)
        else:
            warning = tm.assert_produces_warning(DeprecationWarning,
                                                 check_stacklevel=False)
        with warning:
            with provisionalcompleter("ignore"):
                list(ip.Completer.completions("c.", 1))
Esempio n. 27
0
    async def test_tab_complete_warning(self, ip):
        # https://github.com/pandas-dev/pandas/issues/16409
        pytest.importorskip("IPython", minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "import pandas as pd; s = pd.Series()"
        await ip.run_code(code)

        # TODO: remove it when Ipython updates
        # GH 33567, jedi version raises Deprecation warning in Ipython
        import jedi

        if jedi.__version__ < "0.17.0":
            warning = tm.assert_produces_warning(None)
        else:
            warning = tm.assert_produces_warning(DeprecationWarning,
                                                 check_stacklevel=False)
        with warning:
            with provisionalcompleter("ignore"):
                list(ip.Completer.completions("s.", 1))
    def test_deduplicate_completions(self):
        """
        Test that completions are correctly deduplicated (even if ranges are not the same)
        """
        ip = get_ipython()
        ip.ex(
            textwrap.dedent("""
        class Z:
            zoo = 1
        """))
        with provisionalcompleter():
            ip.Completer.use_jedi = True
            l = list(
                _deduplicate_completions("Z.z",
                                         ip.Completer.completions("Z.z", 3)))
            ip.Completer.use_jedi = False

        assert len(
            l) == 1, "Completions (Z.z<tab>) correctly deduplicate: %s " % l
        assert l[0].text == "zoo"  # and not `it.accumulate`
Esempio n. 29
0
    async def test_tab_complete_warning(self, ip):
        # GH 16409
        pytest.importorskip("IPython", minversion="6.0.0")
        from IPython.core.completer import provisionalcompleter

        code = "from pandas import DataFrame; df = DataFrame()"
        await ip.run_code(code)

        # TODO: remove it when Ipython updates
        # GH 33567, jedi version raises Deprecation warning in Ipython
        import jedi

        if jedi.__version__ < "0.17.0":
            warning = tm.assert_produces_warning(None)
        else:
            warning = tm.assert_produces_warning(DeprecationWarning,
                                                 check_stacklevel=False)
        with warning:
            with provisionalcompleter("ignore"):
                list(ip.Completer.completions("df.", 1))
async def test_tab_complete_ipython6_warning(ip):
    from IPython.core.completer import provisionalcompleter

    code = dedent("""\
    import pandas._testing as tm
    s = tm.makeTimeSeries()
    rs = s.resample("D")
    """)
    await ip.run_code(code)

    # TODO: remove it when Ipython updates
    # GH 33567, jedi version raises Deprecation warning in Ipython
    import jedi

    if jedi.__version__ < "0.17.0":
        warning = tm.assert_produces_warning(None)
    else:
        warning = tm.assert_produces_warning(DeprecationWarning,
                                             check_stacklevel=False)
    with warning:
        with provisionalcompleter("ignore"):
            list(ip.Completer.completions("rs.", 1))
Esempio n. 31
0
    def _experimental_do_complete(self, code, cursor_pos):
        """
        Experimental completions from IPython, using Jedi. 
        """
        if cursor_pos is None:
            cursor_pos = len(code)
        with provisionalcompleter():
            raw_completions = self.shell.Completer.completions(
                code, cursor_pos)
            completions = list(rectify_completions(code, raw_completions))

            comps = []
            for comp in completions:
                comps.append(
                    dict(
                        start=comp.start,
                        end=comp.end,
                        text=comp.text,
                        type=comp.type,
                    ))

        if completions:
            s = completions[0].start
            e = completions[0].end
            matches = [c.text for c in completions]
        else:
            s = cursor_pos
            e = cursor_pos
            matches = []

        return {
            'matches': matches,
            'cursor_end': e,
            'cursor_start': s,
            'metadata': {
                _EXPERIMENTAL_KEY_NAME: comps
            },
            'status': 'ok'
        }
Esempio n. 32
0
    def get_completions(self, document, complete_event):
        if not document.current_line.strip():
            return
        # Some bits of our completion system may print stuff (e.g. if a module
        # is imported). This context manager ensures that doesn't interfere with
        # the prompt.

        with patch_stdout(), provisionalcompleter():
            body = document.text
            cursor_row = document.cursor_position_row
            cursor_col = document.cursor_position_col
            cursor_position = document.cursor_position
            offset = cursor_to_position(body, cursor_row, cursor_col)
            try:
                yield from self._get_completions(body, offset, cursor_position,
                                                 self.ipy_completer)
            except Exception as e:
                try:
                    exc_type, exc_value, exc_tb = sys.exc_info()
                    traceback.print_exception(exc_type, exc_value, exc_tb)
                except AttributeError:
                    print('Unrecoverable Error in completions')
def test_simple_completion(
    greedy_jedi_config_type: GreedyJediConfigType,
    completion_type: CompletionType,
    rt_data: Union[FastArray, Dataset, Categorical, Struct],
):
    ip = get_ipython()
    ip.user_ns["d"] = rt_data

    completions: list
    text = get_completion_text(completion_type)
    with provisionalcompleter():
        if greedy_jedi_config_type == GreedyJediConfigType.GREEDY_JEDI:
            with greedy_completion():
                with jedi_completion():
                    completions = list(
                        ip.Completer.completions(text, len(text)))
        elif greedy_jedi_config_type == GreedyJediConfigType.GREEDY:
            with greedy_completion():
                completions = list(ip.Completer.completions(text, len(text)))
        elif greedy_jedi_config_type == GreedyJediConfigType.JEDI:
            with jedi_completion():
                completions = list(ip.Completer.completions(text, len(text)))
        elif greedy_jedi_config_type == GreedyJediConfigType.NEITHER:
            completions = list(ip.Completer.completions(text, len(text)))
        else:
            raise ValueError(
                "test_simple_completion: could not handle greedy_jedi_config_type {} of type {}"
                .format(greedy_jedi_config_type,
                        type(greedy_jedi_config_type)))

    matches = [completion.text for completion in completions]
    if isinstance(rt_data, Categorical):
        rt_data = rt_data.categories()
    if _get_key_names(rt_data):
        for key in rt_data.keys():
            assert True, key in matches
Esempio n. 34
0
 def _test_not_complete(reason, s, comp):
     l = len(s)
     with provisionalcompleter():
         completions = set(ip.Completer.completions(s, l))
         assert_not_in(Completion(l, l, comp), completions, reason)
Esempio n. 35
0
 def _(line, cursor_pos, expect, message, completion):
     _, c = ip.complete('.', line=line, cursor_pos=cursor_pos)
     with provisionalcompleter():
         completions = ip.Completer.completions(line, cursor_pos)
     nt.assert_in(expect, c, message % c)
     nt.assert_in(completion, completions)
Esempio n. 36
0
def test_omit__names():
    # also happens to test IPCompleter as a configurable
    ip = get_ipython()
    ip._hidden_attr = 1
    ip._x = {}
    c = ip.Completer
    ip.ex('ip=get_ipython()')
    cfg = Config()
    cfg.IPCompleter.omit__names = 0
    c.update_config(cfg)
    with provisionalcompleter():
        c.use_jedi = False
        s,matches = c.complete('ip.')
        nt.assert_in('ip.__str__', matches)
        nt.assert_in('ip._hidden_attr', matches)

        # c.use_jedi = True
        # completions = set(c.completions('ip.', 3))
        # nt.assert_in(Completion(3, 3, '__str__'), completions)
        # nt.assert_in(Completion(3,3, "_hidden_attr"), completions)


    cfg = Config()
    cfg.IPCompleter.omit__names = 1
    c.update_config(cfg)
    with provisionalcompleter():
        c.use_jedi = False
        s,matches = c.complete('ip.')
        nt.assert_not_in('ip.__str__', matches)
        # nt.assert_in('ip._hidden_attr', matches)

        # c.use_jedi = True
        # completions = set(c.completions('ip.', 3))
        # nt.assert_not_in(Completion(3,3,'__str__'), completions)
        # nt.assert_in(Completion(3,3, "_hidden_attr"), completions)

    cfg = Config()
    cfg.IPCompleter.omit__names = 2
    c.update_config(cfg)
    with provisionalcompleter():
        c.use_jedi = False
        s,matches = c.complete('ip.')
        nt.assert_not_in('ip.__str__', matches)
        nt.assert_not_in('ip._hidden_attr', matches)

        # c.use_jedi = True
        # completions = set(c.completions('ip.', 3))
        # nt.assert_not_in(Completion(3,3,'__str__'), completions)
        # nt.assert_not_in(Completion(3,3, "_hidden_attr"), completions)

    with provisionalcompleter():
        c.use_jedi = False
        s,matches = c.complete('ip._x.')
        nt.assert_in('ip._x.keys', matches)

        # c.use_jedi = True
        # completions = set(c.completions('ip._x.', 6))
        # nt.assert_in(Completion(6,6, "keys"), completions)

    del ip._hidden_attr
    del ip._x
Esempio n. 37
0
 def _test_not_complete(reason, s, comp):
     l = len(s)
     with provisionalcompleter():
         completions = set(ip.Completer.completions(s, l))
         assert_not_in(Completion(l, l, comp), completions, reason)