forked from VimPlug/jedi
add a separate docstring testing file, #181
This commit is contained in:
36
test/test_docstring.py
Normal file
36
test/test_docstring.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import jedi
|
||||||
|
from .base import unittest
|
||||||
|
|
||||||
|
|
||||||
|
class TestDocstring(unittest.TestCase):
|
||||||
|
def test_function_doc(self):
|
||||||
|
defs = jedi.Script("""
|
||||||
|
def func():
|
||||||
|
'''Docstring of `func`.'''
|
||||||
|
func""").goto_definitions()
|
||||||
|
self.assertEqual(defs[0].raw_doc, 'Docstring of `func`.')
|
||||||
|
|
||||||
|
@unittest.skip('need evaluator class for that')
|
||||||
|
def test_attribute_docstring(self):
|
||||||
|
defs = jedi.Script("""
|
||||||
|
x = None
|
||||||
|
'''Docstring of `x`.'''
|
||||||
|
x""").goto_definitions()
|
||||||
|
self.assertEqual(defs[0].raw_doc, 'Docstring of `x`.')
|
||||||
|
|
||||||
|
@unittest.skip('need evaluator class for that')
|
||||||
|
def test_multiple_docstrings(self):
|
||||||
|
defs = jedi.Script("""
|
||||||
|
def func():
|
||||||
|
'''Original docstring.'''
|
||||||
|
x = func
|
||||||
|
'''Docstring of `x`.'''
|
||||||
|
x""").goto_definitions()
|
||||||
|
docs = [d.raw_doc for d in defs]
|
||||||
|
self.assertEqual(docs, ['Original docstring.', 'Docstring of `x`.'])
|
||||||
|
|
||||||
|
def test_completion(self):
|
||||||
|
assert jedi.Script('''
|
||||||
|
class DocstringCompletion():
|
||||||
|
#? []
|
||||||
|
""" asdfas """''').completions()
|
||||||
@@ -347,41 +347,6 @@ class TestRegression(TestBase):
|
|||||||
assert self.completions(s)
|
assert self.completions(s)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestDocstring(TestBase):
|
|
||||||
def test_function_doc(self):
|
|
||||||
defs = self.goto_definitions("""
|
|
||||||
def func():
|
|
||||||
'''Docstring of `func`.'''
|
|
||||||
func""")
|
|
||||||
self.assertEqual(defs[0].raw_doc, 'Docstring of `func`.')
|
|
||||||
|
|
||||||
@unittest.skip('need evaluator class for that')
|
|
||||||
def test_attribute_docstring(self):
|
|
||||||
defs = self.goto_definitions("""
|
|
||||||
x = None
|
|
||||||
'''Docstring of `x`.'''
|
|
||||||
x""")
|
|
||||||
self.assertEqual(defs[0].raw_doc, 'Docstring of `x`.')
|
|
||||||
|
|
||||||
@unittest.skip('need evaluator class for that')
|
|
||||||
def test_multiple_docstrings(self):
|
|
||||||
defs = self.goto_definitions("""
|
|
||||||
def func():
|
|
||||||
'''Original docstring.'''
|
|
||||||
x = func
|
|
||||||
'''Docstring of `x`.'''
|
|
||||||
x""")
|
|
||||||
docs = [d.raw_doc for d in defs]
|
|
||||||
self.assertEqual(docs, ['Original docstring.', 'Docstring of `x`.'])
|
|
||||||
|
|
||||||
def test_completion(self):
|
|
||||||
assert self.completions('''
|
|
||||||
class DocstringCompletion():
|
|
||||||
#? []
|
|
||||||
""" asdfas """''')
|
|
||||||
|
|
||||||
|
|
||||||
class TestFeature(TestBase):
|
class TestFeature(TestBase):
|
||||||
def test_preload_modules(self):
|
def test_preload_modules(self):
|
||||||
def check_loaded(*modules):
|
def check_loaded(*modules):
|
||||||
|
|||||||
Reference in New Issue
Block a user