forked from VimPlug/jedi
Writing tests for the upcoming side effect fixes in the interpreter completion.
This commit is contained in:
@@ -6,6 +6,10 @@ from ..helpers import TestCase
|
|||||||
import jedi
|
import jedi
|
||||||
from jedi._compatibility import is_py33
|
from jedi._compatibility import is_py33
|
||||||
|
|
||||||
|
class _GlobalNameSpace():
|
||||||
|
class SideEffectContainer():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_completion(source, namespace):
|
def get_completion(source, namespace):
|
||||||
i = jedi.Interpreter(source, [namespace])
|
i = jedi.Interpreter(source, [namespace])
|
||||||
@@ -35,6 +39,27 @@ def test_builtin_details():
|
|||||||
assert m.type == 'module'
|
assert m.type == 'module'
|
||||||
|
|
||||||
|
|
||||||
|
def test_nested_resolve():
|
||||||
|
class X():
|
||||||
|
def x():
|
||||||
|
pass
|
||||||
|
|
||||||
|
cls = get_completion('X', locals())
|
||||||
|
func = get_completion('X.x', locals())
|
||||||
|
assert func.start_pos == (func.start_pos[0] + 1, 8)
|
||||||
|
|
||||||
|
|
||||||
|
def test_side_effect_completion():
|
||||||
|
"""
|
||||||
|
In the repl it's possible to cause side effects that are not documented in
|
||||||
|
Python code, however we want references to Python code as well. Therefore
|
||||||
|
we need some mixed kind of magic for tests.
|
||||||
|
"""
|
||||||
|
_GlobalNameSpace.SideEffectContainer.foo = 1
|
||||||
|
foo = get_completion('foo', _GlobalNameSpace.__dict__)
|
||||||
|
assert foo.name == 'foo'
|
||||||
|
|
||||||
|
|
||||||
class TestInterpreterAPI(TestCase):
|
class TestInterpreterAPI(TestCase):
|
||||||
def check_interpreter_complete(self, source, namespace, completions,
|
def check_interpreter_complete(self, source, namespace, completions,
|
||||||
**kwds):
|
**kwds):
|
||||||
|
|||||||
Reference in New Issue
Block a user