forked from VimPlug/jedi
Some testing fixes that were broken with the few previous commits.
This commit is contained in:
@@ -437,18 +437,17 @@ def names(source=None, path=None, encoding='utf-8', all_scopes=False,
|
|||||||
is_def = _def._name.tree_name.is_definition()
|
is_def = _def._name.tree_name.is_definition()
|
||||||
return definitions and is_def or references and not is_def
|
return definitions and is_def or references and not is_def
|
||||||
|
|
||||||
def get_definitions():
|
|
||||||
for tree_name in get_module_names(script._get_module_node(), all_scopes):
|
|
||||||
name = TreeNameDefinition(
|
|
||||||
module_context.create_context(tree_name),
|
|
||||||
tree_name
|
|
||||||
)
|
|
||||||
yield classes.Definition(script._evaluator, name)
|
|
||||||
|
|
||||||
# Set line/column to a random position, because they don't matter.
|
# Set line/column to a random position, because they don't matter.
|
||||||
script = Script(source, line=1, column=0, path=path, encoding=encoding)
|
script = Script(source, line=1, column=0, path=path, encoding=encoding)
|
||||||
module_context = script._get_module()
|
module_context = script._get_module()
|
||||||
defs = [
|
defs = [
|
||||||
|
classes.Definition(
|
||||||
|
script._evaluator,
|
||||||
|
TreeNameDefinition(
|
||||||
|
module_context.create_context(name.parent),
|
||||||
|
name
|
||||||
|
)
|
||||||
|
) for name in get_module_names(script._get_module_node(), all_scopes)
|
||||||
]
|
]
|
||||||
return sorted(filter(def_ref_filter, defs), key=lambda x: (x.line, x.column))
|
return sorted(filter(def_ref_filter, defs), key=lambda x: (x.line, x.column))
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ class BaseDefinition(object):
|
|||||||
|
|
||||||
_tuple_mapping = dict((tuple(k.split('.')), v) for (k, v) in {
|
_tuple_mapping = dict((tuple(k.split('.')), v) for (k, v) in {
|
||||||
'argparse._ActionsContainer': 'argparse.ArgumentParser',
|
'argparse._ActionsContainer': 'argparse.ArgumentParser',
|
||||||
'_sre.SRE_Match': 're.MatchObject',
|
|
||||||
'_sre.SRE_Pattern': 're.RegexObject',
|
|
||||||
}.items())
|
}.items())
|
||||||
|
|
||||||
def __init__(self, evaluator, name):
|
def __init__(self, evaluator, name):
|
||||||
@@ -777,6 +775,8 @@ class _Help(object):
|
|||||||
# TODO: Use all of the followed objects as input to Documentation.
|
# TODO: Use all of the followed objects as input to Documentation.
|
||||||
context = next(iter(followed))
|
context = next(iter(followed))
|
||||||
return context.get_node()
|
return context.get_node()
|
||||||
|
if self._name.tree_name is None:
|
||||||
|
return None
|
||||||
return self._name.tree_name.get_definition()
|
return self._name.tree_name.get_definition()
|
||||||
|
|
||||||
def full(self, fast=True):
|
def full(self, fast=True):
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class TestFullNameWithGotoDefinitions(MixinTestFullName, TestCase):
|
|||||||
self.check("""
|
self.check("""
|
||||||
import re
|
import re
|
||||||
any_re = re.compile('.*')
|
any_re = re.compile('.*')
|
||||||
any_re""", '_sre.compile.SRE_Pattern')
|
any_re""", '_sre.SRE_Pattern')
|
||||||
|
|
||||||
def test_from_import(self):
|
def test_from_import(self):
|
||||||
self.check('from os import path', 'os.path')
|
self.check('from os import path', 'os.path')
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ def test_not_importable_file():
|
|||||||
def test_import_unique():
|
def test_import_unique():
|
||||||
src = "import os; os.path"
|
src = "import os; os.path"
|
||||||
defs = jedi.Script(src, path='example.py').goto_definitions()
|
defs = jedi.Script(src, path='example.py').goto_definitions()
|
||||||
defs = [d._name.parent_context for d in defs]
|
parent_contexts = [d._name._context for d in defs]
|
||||||
assert len(defs) == len(set(defs))
|
assert len(parent_contexts) == len(set(parent_contexts))
|
||||||
|
|
||||||
|
|
||||||
def test_cache_works_with_sys_path_param(tmpdir):
|
def test_cache_works_with_sys_path_param(tmpdir):
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ from jedi import Script
|
|||||||
|
|
||||||
|
|
||||||
def get_definition_and_evaluator(source):
|
def get_definition_and_evaluator(source):
|
||||||
d = Script(dedent(source)).goto_definitions()[0]
|
first, = Script(dedent(source)).goto_definitions()
|
||||||
return d._name.parent_context, d._evaluator
|
return first._name._context, first._evaluator
|
||||||
|
|
||||||
|
|
||||||
def test_function_execution():
|
def test_function_execution():
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class TokenTest(unittest.TestCase):
|
|||||||
def test_tokenizer_with_string_literal_backslash():
|
def test_tokenizer_with_string_literal_backslash():
|
||||||
import jedi
|
import jedi
|
||||||
c = jedi.Script("statement = u'foo\\\n'; statement").goto_definitions()
|
c = jedi.Script("statement = u'foo\\\n'; statement").goto_definitions()
|
||||||
assert c[0]._name.parent_context.obj == 'foo'
|
assert c[0]._name._context.obj == 'foo'
|
||||||
|
|
||||||
|
|
||||||
def test_ur_literals():
|
def test_ur_literals():
|
||||||
|
|||||||
Reference in New Issue
Block a user