mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 22:44:27 +08:00
add test_integration_keyword.py to test keywords (moved out of test_regression), #181
This commit is contained in:
39
test/test_integration_keyword.py
Normal file
39
test/test_integration_keyword.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import jedi
|
||||||
|
from jedi import Script, common
|
||||||
|
|
||||||
|
def test_goto_assignments_keyword():
|
||||||
|
"""
|
||||||
|
Bug: goto assignments on ``in`` used to raise AttributeError::
|
||||||
|
|
||||||
|
'unicode' object has no attribute 'generate_call_path'
|
||||||
|
"""
|
||||||
|
Script('in').goto_assignments()
|
||||||
|
|
||||||
|
def test_keyword_doc():
|
||||||
|
r = list(Script("or", 1, 1).goto_definitions())
|
||||||
|
assert len(r) == 1
|
||||||
|
assert len(r[0].doc) > 100
|
||||||
|
|
||||||
|
r = list(Script("asfdasfd", 1, 1).goto_definitions())
|
||||||
|
assert len(r) == 0
|
||||||
|
|
||||||
|
k = Script("fro").completions()[0]
|
||||||
|
imp_start = '\nThe ``import'
|
||||||
|
assert k.raw_doc.startswith(imp_start)
|
||||||
|
assert k.doc.startswith(imp_start)
|
||||||
|
|
||||||
|
def test_keyword():
|
||||||
|
""" github jedi-vim issue #44 """
|
||||||
|
defs = Script("print").goto_definitions()
|
||||||
|
assert [d.doc for d in defs]
|
||||||
|
|
||||||
|
defs = Script("import").goto_definitions()
|
||||||
|
assert len(defs) == 1 and [1 for d in defs if d.doc]
|
||||||
|
# unrelated to #44
|
||||||
|
defs = Script("import").goto_assignments()
|
||||||
|
assert len(defs) == 0
|
||||||
|
completions = Script("import", 1,1).completions()
|
||||||
|
assert len(completions) == 0
|
||||||
|
with common.ignored(jedi.NotFoundError): # TODO shouldn't throw that.
|
||||||
|
defs = Script("assert").goto_definitions()
|
||||||
|
assert len(defs) == 1
|
||||||
@@ -54,19 +54,6 @@ class TestRegression(unittest.TestCase):
|
|||||||
|
|
||||||
self.assertRaises(jedi.NotFoundError, get_def, cls)
|
self.assertRaises(jedi.NotFoundError, get_def, cls)
|
||||||
|
|
||||||
def test_keyword_doc(self):
|
|
||||||
r = list(Script("or", 1, 1).goto_definitions())
|
|
||||||
assert len(r) == 1
|
|
||||||
assert len(r[0].doc) > 100
|
|
||||||
|
|
||||||
r = list(Script("asfdasfd", 1, 1).goto_definitions())
|
|
||||||
assert len(r) == 0
|
|
||||||
|
|
||||||
k = Script("fro").completions()[0]
|
|
||||||
imp_start = '\nThe ``import'
|
|
||||||
assert k.raw_doc.startswith(imp_start)
|
|
||||||
assert k.doc.startswith(imp_start)
|
|
||||||
|
|
||||||
def test_operator_doc(self):
|
def test_operator_doc(self):
|
||||||
r = list(Script("a == b", 1, 3).goto_definitions())
|
r = list(Script("a == b", 1, 3).goto_definitions())
|
||||||
assert len(r) == 1
|
assert len(r) == 1
|
||||||
@@ -122,30 +109,6 @@ class TestRegression(unittest.TestCase):
|
|||||||
s = Script("import os; os.P_").completions()
|
s = Script("import os; os.P_").completions()
|
||||||
assert 'P_NOWAIT' in [i.name for i in s]
|
assert 'P_NOWAIT' in [i.name for i in s]
|
||||||
|
|
||||||
def test_keyword(self):
|
|
||||||
""" github jedi-vim issue #44 """
|
|
||||||
defs = Script("print").goto_definitions()
|
|
||||||
assert [d.doc for d in defs]
|
|
||||||
|
|
||||||
defs = Script("import").goto_definitions()
|
|
||||||
assert len(defs) == 1 and [1 for d in defs if d.doc]
|
|
||||||
# unrelated to #44
|
|
||||||
defs = Script("import").goto_assignments()
|
|
||||||
assert len(defs) == 0
|
|
||||||
completions = Script("import", 1,1).completions()
|
|
||||||
assert len(completions) == 0
|
|
||||||
with common.ignored(jedi.NotFoundError): # TODO shouldn't throw that.
|
|
||||||
defs = Script("assert").goto_definitions()
|
|
||||||
assert len(defs) == 1
|
|
||||||
|
|
||||||
def test_goto_assignments_keyword(self):
|
|
||||||
"""
|
|
||||||
Bug: goto assignments on ``in`` used to raise AttributeError::
|
|
||||||
|
|
||||||
'unicode' object has no attribute 'generate_call_path'
|
|
||||||
"""
|
|
||||||
Script('in').goto_assignments()
|
|
||||||
|
|
||||||
def test_points_in_completion(self):
|
def test_points_in_completion(self):
|
||||||
"""At some point, points were inserted into the completions, this
|
"""At some point, points were inserted into the completions, this
|
||||||
caused problems, sometimes.
|
caused problems, sometimes.
|
||||||
|
|||||||
Reference in New Issue
Block a user