1
0
forked from VimPlug/jedi
Also modify the test a bit to make sure that it passes properly if there are
folders present.
This commit is contained in:
Dave Halter
2020-03-13 23:38:19 +01:00
2 changed files with 16 additions and 1 deletions

View File

@@ -17,6 +17,8 @@ def complete_file_name(inference_state, module_context, start_leaf, string,
like_name_length = len(os.path.basename(string)) like_name_length = len(os.path.basename(string))
addition = _get_string_additions(module_context, start_leaf) addition = _get_string_additions(module_context, start_leaf)
if string.startswith('~'):
string = os.path.expanduser(string)
if addition is None: if addition is None:
return return
string = addition + string string = addition + string

View File

@@ -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 os
import sys import sys
from textwrap import dedent from textwrap import dedent
@@ -7,6 +7,7 @@ import pytest
from ..helpers import root_dir from ..helpers import root_dir
from jedi.api.helpers import start_match, fuzzy_match from jedi.api.helpers import start_match, fuzzy_match
from jedi._compatibility import scandir
def test_in_whitespace(Script): 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) 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): def test_fake_subnodes(Script):
""" """
Test the number of subnodes of a fake object. Test the number of subnodes of a fake object.