mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
Start testing the typeshed directory search
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
from pkg_resources import resource_filename
|
||||||
|
|
||||||
from jedi._compatibility import FileNotFoundError
|
from jedi._compatibility import FileNotFoundError
|
||||||
from jedi.plugins.base import BasePlugin
|
from jedi.plugins.base import BasePlugin
|
||||||
@@ -8,11 +9,7 @@ from jedi.evaluate.base_context import Context, ContextSet
|
|||||||
from jedi.evaluate.context import ModuleContext
|
from jedi.evaluate.context import ModuleContext
|
||||||
|
|
||||||
|
|
||||||
_TYPESHED_PATH = os.path.join(
|
_TYPESHED_PATH = resource_filename('jedi', os.path.join('third_party', 'typeshed'))
|
||||||
os.path.dirname(os.path.dirname(__file__)),
|
|
||||||
'third_party',
|
|
||||||
'typeshed',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _create_stub_map(directory):
|
def _create_stub_map(directory):
|
||||||
@@ -125,6 +122,8 @@ class StubProxy(object):
|
|||||||
typeshed_results = self._stub_context.py__getattribute__(
|
typeshed_results = self._stub_context.py__getattribute__(
|
||||||
*args, **kwargs
|
*args, **kwargs
|
||||||
)
|
)
|
||||||
|
print()
|
||||||
|
print(context_results, typeshed_results)
|
||||||
return context_results
|
return context_results
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
|
|||||||
26
test/test_plugin/test_stub.py
Normal file
26
test/test_plugin/test_stub.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from jedi.plugins import typeshed
|
||||||
|
from parso.utils import PythonVersionInfo
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_typeshed_directories():
|
||||||
|
def get_dirs(version_info):
|
||||||
|
return {
|
||||||
|
d.replace(typeshed._TYPESHED_PATH, '').lstrip(os.path.sep)
|
||||||
|
for d in typeshed._get_typeshed_directories(version_info)
|
||||||
|
}
|
||||||
|
|
||||||
|
dirs = get_dirs(PythonVersionInfo(2, 7))
|
||||||
|
assert dirs == {'stdlib/2and3', 'stdlib/2', 'third_party/2and3', 'third_party/2'}
|
||||||
|
|
||||||
|
dirs = get_dirs(PythonVersionInfo(3, 4))
|
||||||
|
assert dirs == {'stdlib/2and3', 'stdlib/3', 'third_party/2and3', 'third_party/3'}
|
||||||
|
|
||||||
|
dirs = get_dirs(PythonVersionInfo(3, 5))
|
||||||
|
assert dirs == {'stdlib/2and3', 'stdlib/3', 'stdlib/3.5',
|
||||||
|
'third_party/2and3', 'third_party/3', 'third_party/3.5'}
|
||||||
|
|
||||||
|
dirs = get_dirs(PythonVersionInfo(3, 6))
|
||||||
|
assert dirs == {'stdlib/2and3', 'stdlib/3', 'stdlib/3.5', 'stdlib/3.6',
|
||||||
|
'third_party/2and3', 'third_party/3', 'third_party/3.5', 'third_party/3.6'}
|
||||||
Reference in New Issue
Block a user