1
0
forked from VimPlug/jedi

Use Script in more places

This commit is contained in:
Dave Halter
2017-12-29 18:43:10 +01:00
parent da211aa63d
commit 181fe38c17
3 changed files with 12 additions and 15 deletions

View File

@@ -2,15 +2,13 @@
Test all things related to the ``jedi.cache`` module. Test all things related to the ``jedi.cache`` module.
""" """
import jedi
def test_cache_call_signatures(Script):
def test_cache_call_signatures():
""" """
See github issue #390. See github issue #390.
""" """
def check(column, call_name, path=None): def check(column, call_name, path=None):
assert jedi.Script(s, 1, column, path).call_signatures()[0].name == call_name assert Script(s, 1, column, path).call_signatures()[0].name == call_name
s = 'str(int())' s = 'str(int())'
@@ -26,6 +24,6 @@ def test_cache_call_signatures():
check(4, 'str', 'boo') check(4, 'str', 'boo')
def test_cache_line_split_issues(): def test_cache_line_split_issues(Script):
"""Should still work even if there's a newline.""" """Should still work even if there's a newline."""
assert jedi.Script('int(\n').call_signatures()[0].name == 'int' assert Script('int(\n').call_signatures()[0].name == 'int'

View File

@@ -2,10 +2,9 @@
Test of keywords and ``jedi.keywords`` Test of keywords and ``jedi.keywords``
""" """
from jedi._compatibility import is_py3 from jedi._compatibility import is_py3
from jedi import Script
def test_goto_assignments_keyword(): def test_goto_assignments_keyword(Script):
""" """
Bug: goto assignments on ``in`` used to raise AttributeError:: Bug: goto assignments on ``in`` used to raise AttributeError::
@@ -14,7 +13,7 @@ def test_goto_assignments_keyword():
Script('in').goto_assignments() Script('in').goto_assignments()
def test_keyword(): def test_keyword(Script):
""" github jedi-vim issue #44 """ """ github jedi-vim issue #44 """
defs = Script("print").goto_definitions() defs = Script("print").goto_definitions()
if is_py3: if is_py3:

View File

@@ -31,29 +31,29 @@ def _check_speed(time_per_run, number=4, run_warm=True):
@_check_speed(0.2) @_check_speed(0.2)
def test_os_path_join(): def test_os_path_join(Script):
s = "from posixpath import join; join('', '')." s = "from posixpath import join; join('', '')."
assert len(jedi.Script(s).completions()) > 10 # is a str completion assert len(Script(s).completions()) > 10 # is a str completion
@_check_speed(0.15) @_check_speed(0.15)
def test_scipy_speed(): def test_scipy_speed(Script):
s = 'import scipy.weave; scipy.weave.inline(' s = 'import scipy.weave; scipy.weave.inline('
script = jedi.Script(s, 1, len(s), '') script = Script(s, 1, len(s), '')
script.call_signatures() script.call_signatures()
#print(jedi.imports.imports_processed) #print(jedi.imports.imports_processed)
@_check_speed(0.8) @_check_speed(0.8)
@cwd_at('test') @cwd_at('test')
def test_precedence_slowdown(): def test_precedence_slowdown(Script):
""" """
Precedence calculation can slow down things significantly in edge Precedence calculation can slow down things significantly in edge
cases. Having strange recursion structures increases the problem. cases. Having strange recursion structures increases the problem.
""" """
with open('speed/precedence.py') as f: with open('speed/precedence.py') as f:
line = len(f.read().splitlines()) line = len(f.read().splitlines())
assert jedi.Script(line=line, path='speed/precedence.py').goto_definitions() assert Script(line=line, path='speed/precedence.py').goto_definitions()
@_check_speed(0.1) @_check_speed(0.1)