diff --git a/test/test_docstring.py b/test/test_docstring.py new file mode 100644 index 00000000..c2feb1e8 --- /dev/null +++ b/test/test_docstring.py @@ -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() diff --git a/test/test_regression.py b/test/test_regression.py index b713b34a..ea0bee4a 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -347,41 +347,6 @@ class TestRegression(TestBase): 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): def test_preload_modules(self): def check_loaded(*modules):