1
0
forked from VimPlug/jedi

Writing tests for the upcoming side effect fixes in the interpreter completion.

This commit is contained in:
Dave Halter
2016-05-16 09:36:54 +02:00
parent 818730d6ea
commit e21b3024e0

View File

@@ -6,6 +6,10 @@ from ..helpers import TestCase
import jedi
from jedi._compatibility import is_py33
class _GlobalNameSpace():
class SideEffectContainer():
pass
def get_completion(source, namespace):
i = jedi.Interpreter(source, [namespace])
@@ -35,6 +39,27 @@ def test_builtin_details():
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):
def check_interpreter_complete(self, source, namespace, completions,
**kwds):