moved more methods out of regression tests, created integration_import and jedi_system, #181

This commit is contained in:
David Halter
2013-08-07 17:41:22 +04:30
parent 5b4ee16317
commit 4e75cda7f6
3 changed files with 109 additions and 60 deletions

View File

@@ -0,0 +1,48 @@
from .base import cwd_at
import itertools
from jedi import Script
def test_goto_definition_on_import():
assert Script("import sys_blabla", 1, 8).goto_definitions() == []
assert len(Script("import sys", 1, 8).goto_definitions()) == 1
@cwd_at('jedi')
def test_complete_on_empty_import():
# should just list the files in the directory
assert 10 < len(Script("from .", source_path='').completions()) < 30
assert 10 < len(Script("from . import", 1, 5, '').completions()) < 30
assert 10 < len(Script("from . import classes", 1, 5, '').completions()) < 30
assert len(Script("import").completions()) == 0
assert len(Script("import import", source_path='').completions()) > 0
# 111
assert Script("from datetime import").completions()[0].name == 'import'
assert Script("from datetime import ").completions()
def test_named_import():
"""named import - jedi-vim issue #8"""
s = "import time as dt"
assert len(Script(s, 1, 15, '/').goto_definitions()) == 1
assert len(Script(s, 1, 10, '/').goto_definitions()) == 1
def test_goto_following_on_imports():
s = "import multiprocessing.dummy; multiprocessing.dummy"
g = Script(s).goto_assignments()
assert len(g) == 1
assert g[0].start_pos != (0, 0)
def test_follow_definition():
""" github issue #45 """
c = Script("from datetime import timedelta; timedelta").completions()
# type can also point to import, but there will be additional
# attributes
objs = itertools.chain.from_iterable(r.follow_definition() for r in c)
types = [o.type for o in objs]
assert 'import' not in types and 'class' in types