mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-20 15:28:25 +08:00
goto_assignment -> goto everywhere where it was left
This commit is contained in:
@@ -28,11 +28,11 @@ def test_sqlite3_conversion(Script):
|
||||
def test_conversion_of_stub_only(Script):
|
||||
project = Project(os.path.join(root_dir, 'test', 'completion', 'stub_folder'))
|
||||
code = 'import stub_only; stub_only.in_stub_only'
|
||||
d1, = Script(code, _project=project).goto_assignments()
|
||||
d1, = Script(code, _project=project).goto()
|
||||
assert d1.is_stub()
|
||||
|
||||
script = Script(path=d1.module_path, line=d1.line, column=d1.column, _project=project)
|
||||
d2, = script.goto_assignments()
|
||||
script = Script(path=d1.module_path, _project=project)
|
||||
d2, = script.goto(line=d1.line, column=d1.column)
|
||||
assert d2.is_stub()
|
||||
assert d2.module_path == d1.module_path
|
||||
assert d2.line == d1.line
|
||||
@@ -43,7 +43,7 @@ def test_conversion_of_stub_only(Script):
|
||||
def test_goto_on_file(Script):
|
||||
project = Project(os.path.join(root_dir, 'test', 'completion', 'stub_folder'))
|
||||
script = Script('import stub_only; stub_only.Foo', _project=project)
|
||||
d1, = script.goto_assignments()
|
||||
d1, = script.goto()
|
||||
v, = d1._name.infer()
|
||||
foo, bar, obj = v.py__mro__()
|
||||
assert foo.py__name__() == 'Foo'
|
||||
@@ -51,6 +51,6 @@ def test_goto_on_file(Script):
|
||||
assert obj.py__name__() == 'object'
|
||||
|
||||
# Make sure we go to Bar, because Foo is a bit before: `class Foo(Bar):`
|
||||
script = Script(path=d1.module_path, line=d1.line, column=d1.column + 4, _project=project)
|
||||
d2, = script.goto_assignments()
|
||||
script = Script(path=d1.module_path, _project=project)
|
||||
d2, = script.goto(line=d1.line, column=d1.column + 4)
|
||||
assert d2.name == 'Bar'
|
||||
|
||||
@@ -64,11 +64,11 @@ def test_infer_and_goto(Script, code, full_name, has_stub, has_python, way,
|
||||
|
||||
if way == 'direct':
|
||||
if type_ == 'goto':
|
||||
defs = s.goto_assignments(follow_imports=True, **kwargs)
|
||||
defs = s.goto(follow_imports=True, **kwargs)
|
||||
else:
|
||||
defs = s.infer(**kwargs)
|
||||
else:
|
||||
goto_defs = s.goto_assignments(
|
||||
goto_defs = s.goto(
|
||||
# Prefering stubs when we want to go to python and vice versa
|
||||
prefer_stubs=not (prefer_stubs or only_stubs),
|
||||
follow_imports=True,
|
||||
|
||||
@@ -159,7 +159,7 @@ def test_math_is_stub(Script, code, full_name):
|
||||
assert cos.goto(only_stubs=True) == [cos]
|
||||
assert cos.full_name == full_name
|
||||
|
||||
cos, = s.goto_assignments()
|
||||
cos, = s.goto()
|
||||
assert cos.module_path.endswith(wanted)
|
||||
assert cos.goto(only_stubs=True) == [cos]
|
||||
assert cos.is_stub() is True
|
||||
@@ -174,7 +174,7 @@ def test_goto_stubs(Script):
|
||||
stub, = os_module.goto(only_stubs=True)
|
||||
assert stub.is_stub() is True
|
||||
|
||||
os_module, = s.goto_assignments()
|
||||
os_module, = s.goto()
|
||||
|
||||
|
||||
def _assert_is_same(d1, d2):
|
||||
@@ -201,7 +201,7 @@ def test_goto_stubs_on_itself(Script, code, type_):
|
||||
if type_ == 'infer':
|
||||
def_, = s.infer()
|
||||
else:
|
||||
def_, = s.goto_assignments(follow_imports=True)
|
||||
def_, = s.goto(follow_imports=True)
|
||||
stub, = def_.goto(only_stubs=True)
|
||||
|
||||
script_on_source = Script(path=def_.module_path)
|
||||
|
||||
@@ -27,7 +27,7 @@ def test_implicit_namespace_package(Script):
|
||||
'from pkg.ns1_file import foo': 'ns1_file!',
|
||||
}
|
||||
for source, solution in tests.items():
|
||||
ass = script_with_path(source).goto_assignments()
|
||||
ass = script_with_path(source).goto()
|
||||
assert len(ass) == 1
|
||||
assert ass[0].description == "foo = '%s'" % solution
|
||||
|
||||
|
||||
@@ -244,13 +244,13 @@ def test_named_import(Script):
|
||||
@pytest.mark.skipif('True', reason='The nested import stuff is still very messy.')
|
||||
def test_goto_following_on_imports(Script):
|
||||
s = "import multiprocessing.dummy; multiprocessing.dummy"
|
||||
g = Script(s).goto_assignments()
|
||||
g = Script(s).goto()
|
||||
assert len(g) == 1
|
||||
assert (g[0].line, g[0].column) != (0, 0)
|
||||
|
||||
|
||||
def test_goto_assignments(Script):
|
||||
sys, = Script("import sys", 1, 10).goto_assignments(follow_imports=True)
|
||||
def test_goto(Script):
|
||||
sys, = Script("import sys", 1, 10).goto(follow_imports=True)
|
||||
assert sys.type == 'module'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user