From e21b3024e02dfa3523aeb6e3bb6d6e93ee3aeaaa Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 16 May 2016 09:36:54 +0200 Subject: [PATCH] Writing tests for the upcoming side effect fixes in the interpreter completion. --- test/test_api/test_interpreter.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/test_api/test_interpreter.py b/test/test_api/test_interpreter.py index b54d9e5f..8de31b9d 100644 --- a/test/test_api/test_interpreter.py +++ b/test/test_api/test_interpreter.py @@ -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):