Evaluator -> InferState

This commit is contained in:
Dave Halter
2019-08-15 00:33:49 +02:00
parent 8157d119a7
commit a5dff65142
62 changed files with 768 additions and 768 deletions

View File

@@ -42,10 +42,10 @@ def test_versions(version):
assert env.get_sys_path()
def test_load_module(evaluator):
access_path = evaluator.compiled_subprocess.load_module(
def test_load_module(infer_state):
access_path = infer_state.compiled_subprocess.load_module(
dotted_name=u'math',
sys_path=evaluator.get_sys_path()
sys_path=infer_state.get_sys_path()
)
name, access_handle = access_path.accesses[0]
@@ -55,31 +55,31 @@ def test_load_module(evaluator):
access_handle.py__mro__()
def test_error_in_environment(evaluator, Script, environment):
def test_error_in_environment(infer_state, Script, environment):
if isinstance(environment, InterpreterEnvironment):
pytest.skip("We don't catch these errors at the moment.")
# Provoke an error to show how Jedi can recover from it.
with pytest.raises(jedi.InternalError):
evaluator.compiled_subprocess._test_raise_error(KeyboardInterrupt)
infer_state.compiled_subprocess._test_raise_error(KeyboardInterrupt)
# The second time it should raise an InternalError again.
with pytest.raises(jedi.InternalError):
evaluator.compiled_subprocess._test_raise_error(KeyboardInterrupt)
infer_state.compiled_subprocess._test_raise_error(KeyboardInterrupt)
# Jedi should still work.
def_, = Script('str').goto_definitions()
assert def_.name == 'str'
def test_stdout_in_subprocess(evaluator, Script):
evaluator.compiled_subprocess._test_print(stdout='.')
def test_stdout_in_subprocess(infer_state, Script):
infer_state.compiled_subprocess._test_print(stdout='.')
Script('1').goto_definitions()
def test_killed_subprocess(evaluator, Script, environment):
def test_killed_subprocess(infer_state, Script, environment):
if isinstance(environment, InterpreterEnvironment):
pytest.skip("We cannot kill our own process")
# Just kill the subprocess.
evaluator.compiled_subprocess._compiled_subprocess._get_process().kill()
infer_state.compiled_subprocess._compiled_subprocess._get_process().kill()
# Since the process was terminated (and nobody knows about it) the first
# Jedi call fails.
with pytest.raises(jedi.InternalError):

View File

@@ -13,12 +13,12 @@ def test_django_default_project(Script):
)
c, = script.completions()
assert c.name == "SomeModel"
assert script._evaluator.project._django is True
assert script._infer_state.project._django is True
def test_interpreter_project_path():
# Run from anywhere it should be the cwd.
dir = os.path.join(root_dir, 'test')
with set_cwd(dir):
project = Interpreter('', [locals()])._evaluator.project
project = Interpreter('', [locals()])._infer_state.project
assert project._path == dir

View File

@@ -17,7 +17,7 @@ def test_add_dynamic_mods(Script):
# Other fictional modules in another place in the fs.
src2 = 'from .. import setup; setup.r(1)'
script = Script(src1, path='../setup.py')
imports.load_module(script._evaluator, os.path.abspath(fname), src2)
imports.load_module(script._infer_state, os.path.abspath(fname), src2)
result = script.goto_definitions()
assert len(result) == 1
assert result[0].description == 'class int'