mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Fix some stub tests
This commit is contained in:
@@ -20,7 +20,7 @@ CompletionParts = namedtuple('CompletionParts', ['path', 'has_dot', 'name'])
|
|||||||
|
|
||||||
def sorted_definitions(defs):
|
def sorted_definitions(defs):
|
||||||
# Note: `or ''` below is required because `module_path` could be
|
# Note: `or ''` below is required because `module_path` could be
|
||||||
return sorted(defs, key=lambda x: (x.module_path or '', x.line or 0, x.column or 0))
|
return sorted(defs, key=lambda x: (x.module_path or '', x.line or 0, x.column or 0, x.name))
|
||||||
|
|
||||||
|
|
||||||
def get_on_completion_name(module_node, lines, position):
|
def get_on_completion_name(module_node, lines, position):
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ def test_keywords_variable(Script):
|
|||||||
code = 'import keyword; keyword.kwlist'
|
code = 'import keyword; keyword.kwlist'
|
||||||
def_, = Script(code).goto_definitions()
|
def_, = Script(code).goto_definitions()
|
||||||
assert def_.name == 'Sequence'
|
assert def_.name == 'Sequence'
|
||||||
# We want this to show towards the actual definition
|
# This points towards the typeshed implementation
|
||||||
assert typeshed._TYPESHED_PATH not in def_.module_path
|
assert typeshed._TYPESHED_PATH in def_.module_path
|
||||||
|
|
||||||
|
|
||||||
def test_class(Script):
|
def test_class(Script):
|
||||||
@@ -91,9 +91,16 @@ def test_method(Script):
|
|||||||
|
|
||||||
|
|
||||||
def test_sys_exc_info(Script):
|
def test_sys_exc_info(Script):
|
||||||
code = 'import sys; sys.exc_info()[1]'
|
code = 'import sys; sys.exc_info()'
|
||||||
def_, = Script(code).goto_definitions()
|
def_, none = Script(code + '[1]').goto_definitions()
|
||||||
|
# It's an optional.
|
||||||
assert def_.name == 'BaseException'
|
assert def_.name == 'BaseException'
|
||||||
|
assert def_.type == 'instance'
|
||||||
|
assert none.name == 'NoneType'
|
||||||
|
|
||||||
|
def_, none = Script(code + '[0]').goto_definitions()
|
||||||
|
assert def_.name == 'BaseException'
|
||||||
|
assert def_.type == 'class'
|
||||||
|
|
||||||
|
|
||||||
def test_sys_getwindowsversion(Script, environment):
|
def test_sys_getwindowsversion(Script, environment):
|
||||||
|
|||||||
Reference in New Issue
Block a user