mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 05:54:25 +08:00
Move the module_injector
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
from itertools import count
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -11,9 +9,6 @@ from . import run
|
||||
from . import refactor
|
||||
from jedi import InterpreterEnvironment, get_system_environment
|
||||
from jedi.inference.compiled.value import create_from_access_path
|
||||
from jedi.inference.imports import _load_python_module
|
||||
from jedi.file_io import KnownContentFileIO
|
||||
from jedi.inference.base_value import ValueSet
|
||||
from jedi.api.interpreter import MixedModuleContext
|
||||
|
||||
# For interpreter tests sometimes the path of this directory is in the sys
|
||||
@@ -164,19 +159,6 @@ def create_compiled_object(inference_state):
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def module_injector():
|
||||
counter = count()
|
||||
|
||||
def module_injector(inference_state, names, code):
|
||||
assert isinstance(names, tuple)
|
||||
file_io = KnownContentFileIO(Path('/foo/bar/module-injector-%s.py') % next(counter), code)
|
||||
v = _load_python_module(inference_state, file_io, names)
|
||||
inference_state.module_cache.add(names, ValueSet([v]))
|
||||
|
||||
return module_injector
|
||||
|
||||
|
||||
@pytest.fixture(params=[False, True])
|
||||
def class_findable(monkeypatch, request):
|
||||
if not request.param:
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
from os.path import join, sep as s, dirname, expanduser
|
||||
import os
|
||||
from textwrap import dedent
|
||||
from itertools import count
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from ..helpers import root_dir
|
||||
from jedi.api.helpers import _start_match, _fuzzy_match
|
||||
from jedi.inference.imports import _load_python_module
|
||||
from jedi.file_io import KnownContentFileIO
|
||||
from jedi.inference.base_value import ValueSet
|
||||
|
||||
|
||||
def test_in_whitespace(Script):
|
||||
@@ -400,6 +405,22 @@ def test_ellipsis_completion(Script):
|
||||
assert Script('...').complete() == []
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def module_injector():
|
||||
counter = count()
|
||||
|
||||
def module_injector(inference_state, names, code):
|
||||
assert isinstance(names, tuple)
|
||||
file_io = KnownContentFileIO(
|
||||
Path('/foo/bar/module-injector-%s.py' % next(counter)),
|
||||
code
|
||||
)
|
||||
v = _load_python_module(inference_state, file_io, names)
|
||||
inference_state.module_cache.add(names, ValueSet([v]))
|
||||
|
||||
return module_injector
|
||||
|
||||
|
||||
def test_completion_cache(Script, module_injector):
|
||||
"""
|
||||
For some modules like numpy, tensorflow or pandas we cache docstrings and
|
||||
|
||||
Reference in New Issue
Block a user