mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-30 08:44:21 +08:00
Compare commits
6 Commits
master
...
383c596975
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
383c596975 | ||
|
|
0ad565b95b | ||
|
|
aa302c58db | ||
|
|
1ce0d00fb6 | ||
|
|
61848afc7c | ||
|
|
a4ec9e0b2b |
@@ -183,10 +183,12 @@ class DirectObjectAccess:
|
|||||||
|
|
||||||
def py__file__(self) -> Optional[Path]:
|
def py__file__(self) -> Optional[Path]:
|
||||||
try:
|
try:
|
||||||
return Path(self._obj.__file__)
|
__file__attribute = self._obj.__file__
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
return Path(__file__attribute) if __file__attribute is not None else None
|
||||||
|
|
||||||
def py__doc__(self):
|
def py__doc__(self):
|
||||||
return inspect.getdoc(self._obj) or ''
|
return inspect.getdoc(self._obj) or ''
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ import pytest
|
|||||||
|
|
||||||
import jedi
|
import jedi
|
||||||
import jedi.settings
|
import jedi.settings
|
||||||
|
from jedi import Project
|
||||||
from jedi.inference.compiled import mixed
|
from jedi.inference.compiled import mixed
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
from test.helpers import get_example_dir
|
||||||
|
|
||||||
|
|
||||||
class _GlobalNameSpace:
|
class _GlobalNameSpace:
|
||||||
@@ -591,6 +593,40 @@ def test_dict_completion(code, column, expected):
|
|||||||
assert [c.complete for c in comps] == expected
|
assert [c.complete for c in comps] == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_implicit_namespace_package_with_subpackages_v1(monkeypatch):
|
||||||
|
sys_path_dir1 = get_example_dir('implicit_namespace_package_with_subpackages', 'ns1')
|
||||||
|
sys_path_dir2 = get_example_dir('implicit_namespace_package_with_subpackages', 'ns2')
|
||||||
|
monkeypatch.syspath_prepend(sys_path_dir1)
|
||||||
|
monkeypatch.syspath_prepend(sys_path_dir2)
|
||||||
|
|
||||||
|
import pkg_implicit_namespace_package_test
|
||||||
|
interpreter = jedi.Interpreter(
|
||||||
|
"pkg_implicit_namespace_package_test.",
|
||||||
|
namespaces=[locals()],
|
||||||
|
project=Project('.')
|
||||||
|
)
|
||||||
|
comps = interpreter.complete()
|
||||||
|
expected = ["pkgA", "pkgB"]
|
||||||
|
assert [c.complete for c in comps] == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_implicit_namespace_package_with_subpackages_v2(monkeypatch):
|
||||||
|
sys_path_dir1 = get_example_dir('implicit_namespace_package_with_subpackages', 'ns1')
|
||||||
|
sys_path_dir2 = get_example_dir('implicit_namespace_package_with_subpackages', 'ns2')
|
||||||
|
monkeypatch.syspath_prepend(sys_path_dir1)
|
||||||
|
monkeypatch.syspath_prepend(sys_path_dir2)
|
||||||
|
|
||||||
|
# import pkg_implicit_namespace_package_test
|
||||||
|
interpreter = jedi.Interpreter(
|
||||||
|
"import pkg_implicit_namespace_package_test.",
|
||||||
|
namespaces=[locals()],
|
||||||
|
project=Project('.')
|
||||||
|
)
|
||||||
|
comps = interpreter.complete()
|
||||||
|
expected = ["pkgA", "pkgB"]
|
||||||
|
assert [c.complete for c in comps] == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'code, types', [
|
'code, types', [
|
||||||
('dct[1]', ['int']),
|
('dct[1]', ['int']),
|
||||||
|
|||||||
Reference in New Issue
Block a user