mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 23:34:45 +08:00
Write a test for variables
This commit is contained in:
@@ -186,6 +186,7 @@ class StubName(TreeNameDefinition):
|
|||||||
for c in stub_contexts:
|
for c in stub_contexts:
|
||||||
yield c
|
yield c
|
||||||
|
|
||||||
|
# This basically merges stub contexts with actual contexts.
|
||||||
for actual_context in actual_contexts:
|
for actual_context in actual_contexts:
|
||||||
for stub_context in stub_contexts:
|
for stub_context in stub_contexts:
|
||||||
if isinstance(stub_context, FunctionContext) \
|
if isinstance(stub_context, FunctionContext) \
|
||||||
|
|||||||
@@ -50,6 +50,14 @@ def test_function(Script):
|
|||||||
assert isinstance(context.class_context, typeshed.StubClassContext), context
|
assert isinstance(context.class_context, typeshed.StubClassContext), context
|
||||||
|
|
||||||
|
|
||||||
|
def test_keywords_variable(Script):
|
||||||
|
code = 'import keyword; keyword.kwlist'
|
||||||
|
def_, = Script(code).goto_definitions()
|
||||||
|
assert def_.name == 'Sequence'
|
||||||
|
# We want this to show towards the actual definition
|
||||||
|
assert typeshed._TYPESHED_PATH not in def_.module_path
|
||||||
|
|
||||||
|
|
||||||
def test_class(Script):
|
def test_class(Script):
|
||||||
def_, = Script('import threading; threading.Thread').goto_definitions()
|
def_, = Script('import threading; threading.Thread').goto_definitions()
|
||||||
context = def_._name._context
|
context = def_._name._context
|
||||||
@@ -102,7 +110,7 @@ def test_sys_hexversion(Script):
|
|||||||
script = Script('import sys; sys.hexversion')
|
script = Script('import sys; sys.hexversion')
|
||||||
def_, = script.completions()
|
def_, = script.completions()
|
||||||
assert isinstance(def_._name, TreeNameDefinition)
|
assert isinstance(def_._name, TreeNameDefinition)
|
||||||
assert typeshed._TYPESHED_PATH in def_._name.get_root_context().py__file__()
|
assert typeshed._TYPESHED_PATH in def_.module_path
|
||||||
def_, = script.goto_definitions()
|
def_, = script.goto_definitions()
|
||||||
assert def_.name == 'int'
|
assert def_.name == 'int'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user