Fix some tests

This commit is contained in:
Dave Halter
2019-04-03 01:04:18 +02:00
parent fa17681cf6
commit f4a6856e54
3 changed files with 12 additions and 12 deletions

View File

@@ -13,6 +13,7 @@ from jedi.cache import memoize_method
from jedi.evaluate import imports from jedi.evaluate import imports
from jedi.evaluate import compiled from jedi.evaluate import compiled
from jedi.evaluate.imports import ImportName from jedi.evaluate.imports import ImportName
from jedi.evaluate.filters import ParamName
from jedi.evaluate.context import FunctionExecutionContext from jedi.evaluate.context import FunctionExecutionContext
from jedi.evaluate.gradual.typeshed import StubOnlyModuleContext from jedi.evaluate.gradual.typeshed import StubOnlyModuleContext
from jedi.api.keywords import KeywordName from jedi.api.keywords import KeywordName
@@ -323,7 +324,9 @@ class BaseDefinition(object):
def infer(self): def infer(self):
tree_name = self._name.tree_name tree_name = self._name.tree_name
parent_context = self._name.parent_context parent_context = self._name.parent_context
if tree_name is None or parent_context is None: # Param names are special because they are not handled by
# the evaluator method.
if tree_name is None or parent_context is None or isinstance(self._name, ParamName):
context_set = self._name.infer() context_set = self._name.infer()
else: else:
context_set = self._evaluator.goto_definitions(parent_context, tree_name) context_set = self._evaluator.goto_definitions(parent_context, tree_name)

View File

@@ -7,7 +7,6 @@ import pytest
from ..helpers import TestCase from ..helpers import TestCase
from jedi import cache from jedi import cache
from jedi.parser_utils import get_call_signature from jedi.parser_utils import get_call_signature
from jedi._compatibility import is_py3
def assert_signature(Script, source, expected_name, expected_index=0, line=None, column=None): def assert_signature(Script, source, expected_name, expected_index=0, line=None, column=None):
@@ -308,18 +307,16 @@ def test_signature_is_definition(Script):
# Now compare all the attributes that a CallSignature must also have. # Now compare all the attributes that a CallSignature must also have.
for attr_name in dir(definition): for attr_name in dir(definition):
dont_scan = ['defined_names', 'parent', 'goto_assignments', 'params'] dont_scan = ['defined_names', 'parent', 'goto_assignments', 'infer', 'params']
if attr_name.startswith('_') or attr_name in dont_scan: if attr_name.startswith('_') or attr_name in dont_scan:
continue continue
# Might trigger some deprecation warnings. attribute = getattr(definition, attr_name)
with warnings.catch_warnings(record=True): signature_attribute = getattr(signature, attr_name)
attribute = getattr(definition, attr_name) if inspect.ismethod(attribute):
signature_attribute = getattr(signature, attr_name) assert attribute() == signature_attribute()
if inspect.ismethod(attribute): else:
assert attribute() == signature_attribute() assert attribute == signature_attribute
else:
assert attribute == signature_attribute
def test_no_signature(Script): def test_no_signature(Script):

View File

@@ -79,7 +79,7 @@ def test_killed_subprocess(evaluator, Script, environment):
if isinstance(environment, InterpreterEnvironment): if isinstance(environment, InterpreterEnvironment):
pytest.skip("We cannot kill our own process") pytest.skip("We cannot kill our own process")
# Just kill the subprocess. # Just kill the subprocess.
evaluator.compiled_subprocess._compiled_subprocess._process.kill() evaluator.compiled_subprocess._compiled_subprocess._get_process().kill()
# Since the process was terminated (and nobody knows about it) the first # Since the process was terminated (and nobody knows about it) the first
# Jedi call fails. # Jedi call fails.
with pytest.raises(jedi.InternalError): with pytest.raises(jedi.InternalError):