mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Merge branch 'master' into refactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from os.path import join, sep as s, dirname
|
||||
from os.path import join, sep as s, dirname, expanduser
|
||||
import os
|
||||
import sys
|
||||
from textwrap import dedent
|
||||
@@ -7,6 +7,7 @@ import pytest
|
||||
|
||||
from ..helpers import root_dir
|
||||
from jedi.api.helpers import _start_match, _fuzzy_match
|
||||
from jedi._compatibility import scandir
|
||||
|
||||
|
||||
def test_in_whitespace(Script):
|
||||
@@ -86,6 +87,18 @@ def test_loading_unicode_files_with_bad_global_charset(Script, monkeypatch, tmpd
|
||||
s.complete(line=2, column=4)
|
||||
|
||||
|
||||
def test_complete_expanduser(Script):
|
||||
possibilities = scandir(expanduser('~'))
|
||||
non_dots = [p for p in possibilities if not p.name.startswith('.') and len(p.name) > 1]
|
||||
item = non_dots[0]
|
||||
line = "'~%s%s'" % (os.sep, item.name)
|
||||
s = Script(line, line=1, column=len(line)-1)
|
||||
expected_name = item.name
|
||||
if item.is_dir():
|
||||
expected_name += os.path.sep
|
||||
assert expected_name in [c.name for c in s.completions()]
|
||||
|
||||
|
||||
def test_fake_subnodes(Script):
|
||||
"""
|
||||
Test the number of subnodes of a fake object.
|
||||
|
||||
@@ -342,7 +342,7 @@ def test_completion_params():
|
||||
|
||||
@pytest.mark.skipif('py_version < 33', reason='inspect.signature was created in 3.3.')
|
||||
def test_completion_param_annotations():
|
||||
# Need to define this function not directly in Python. Otherwise Jedi is to
|
||||
# Need to define this function not directly in Python. Otherwise Jedi is too
|
||||
# clever and uses the Python code instead of the signature object.
|
||||
code = 'def foo(a: 1, b: str, c: int = 1.0) -> bytes: pass'
|
||||
exec_(code, locals())
|
||||
@@ -354,6 +354,10 @@ def test_completion_param_annotations():
|
||||
assert [d.name for d in b.infer()] == ['str']
|
||||
assert {d.name for d in c.infer()} == {'int', 'float'}
|
||||
|
||||
assert a.description == 'param a: 1'
|
||||
assert b.description == 'param b: str'
|
||||
assert c.description == 'param c: int=1.0'
|
||||
|
||||
d, = jedi.Interpreter('foo()', [locals()]).infer()
|
||||
assert d.name == 'bytes'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user