mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
Fix a test for Python 2
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from jedi.plugins import typeshed
|
from jedi.plugins import typeshed
|
||||||
from jedi.evaluate.context import TreeInstance, BoundMethod
|
from jedi.evaluate.context import TreeInstance, BoundMethod, FunctionContext
|
||||||
from parso.utils import PythonVersionInfo
|
from parso.utils import PythonVersionInfo
|
||||||
from jedi.evaluate.filters import TreeNameDefinition
|
from jedi.evaluate.filters import TreeNameDefinition
|
||||||
|
|
||||||
@@ -38,11 +38,18 @@ def test_get_stub_files():
|
|||||||
assert map_['functools'] == os.path.join(TYPESHED_PYTHON3, 'functools.pyi')
|
assert map_['functools'] == os.path.join(TYPESHED_PYTHON3, 'functools.pyi')
|
||||||
|
|
||||||
|
|
||||||
def test_function(Script):
|
def test_function(Script, environment):
|
||||||
|
if environment.version_info.major == 2:
|
||||||
|
# In Python 2, the definitions are a bit weird in typeshed. Therefore
|
||||||
|
# it's for now a FunctionContext.
|
||||||
|
expected = FunctionContext
|
||||||
|
else:
|
||||||
|
expected = typeshed.StubFunctionContext
|
||||||
|
|
||||||
code = 'import threading; threading.current_thread'
|
code = 'import threading; threading.current_thread'
|
||||||
def_, = Script(code).goto_definitions()
|
def_, = Script(code).goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
assert isinstance(context, typeshed.StubFunctionContext), context
|
assert isinstance(context, expected), context
|
||||||
|
|
||||||
def_, = Script(code + '()').goto_definitions()
|
def_, = Script(code + '()').goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
|
|||||||
Reference in New Issue
Block a user