mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-20 02:42:49 +08:00
Use split_lines and python_bytes_to_unicode directly.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
Tests of ``jedi.api.Interpreter``.
|
||||
"""
|
||||
|
||||
from ..helpers import TestCase
|
||||
import jedi
|
||||
from jedi._compatibility import is_py33
|
||||
from jedi.evaluate.compiled import mixed
|
||||
@@ -178,16 +177,37 @@ def test_getitem_side_effects():
|
||||
_assert_interpreter_complete('foo[0].', locals(), [])
|
||||
|
||||
|
||||
def test_property_error():
|
||||
def test_property_error_oldstyle():
|
||||
lst = []
|
||||
class Foo3():
|
||||
@property
|
||||
def bar(self):
|
||||
lst.append(1)
|
||||
raise ValueError
|
||||
|
||||
foo = Foo3()
|
||||
_assert_interpreter_complete('foo.bar', locals(), ['bar'])
|
||||
_assert_interpreter_complete('foo.bar.baz', locals(), [])
|
||||
|
||||
# There should not be side effects
|
||||
assert lst == []
|
||||
|
||||
|
||||
def test_property_error_newstyle():
|
||||
lst = []
|
||||
class Foo3(object):
|
||||
@property
|
||||
def bar(self):
|
||||
lst.append(1)
|
||||
raise ValueError
|
||||
|
||||
foo = Foo3()
|
||||
_assert_interpreter_complete('foo.bar', locals(), ['bar'])
|
||||
_assert_interpreter_complete('foo.bar.baz', locals(), [])
|
||||
|
||||
# There should not be side effects
|
||||
assert lst == []
|
||||
|
||||
|
||||
def test_param_completion():
|
||||
def foo(bar):
|
||||
|
||||
@@ -20,7 +20,22 @@ class TestDocstring(unittest.TestCase):
|
||||
def func():
|
||||
'''Docstring of `func`.'''
|
||||
func""").goto_definitions()
|
||||
self.assertEqual(defs[0].docstring(raw=True), 'Docstring of `func`.')
|
||||
self.assertEqual(defs[0].docstring(), 'func()\n\nDocstring of `func`.')
|
||||
|
||||
def test_class_doc(self):
|
||||
defs = jedi.Script("""
|
||||
class TestClass():
|
||||
'''Docstring of `TestClass`.'''
|
||||
TestClass""").goto_definitions()
|
||||
self.assertEqual(defs[0].docstring(), 'Docstring of `TestClass`.')
|
||||
|
||||
def test_instance_doc(self):
|
||||
defs = jedi.Script("""
|
||||
class TestClass():
|
||||
'''Docstring of `TestClass`.'''
|
||||
tc = TestClass()
|
||||
tc""").goto_definitions()
|
||||
self.assertEqual(defs[0].docstring(), 'Docstring of `TestClass`.')
|
||||
|
||||
@unittest.skip('need evaluator class for that')
|
||||
def test_attribute_docstring(self):
|
||||
@@ -28,7 +43,7 @@ class TestDocstring(unittest.TestCase):
|
||||
x = None
|
||||
'''Docstring of `x`.'''
|
||||
x""").goto_definitions()
|
||||
self.assertEqual(defs[0].docstring(raw=True), 'Docstring of `x`.')
|
||||
self.assertEqual(defs[0].docstring(), 'Docstring of `x`.')
|
||||
|
||||
@unittest.skip('need evaluator class for that')
|
||||
def test_multiple_docstrings(self):
|
||||
@@ -38,7 +53,7 @@ class TestDocstring(unittest.TestCase):
|
||||
x = func
|
||||
'''Docstring of `x`.'''
|
||||
x""").goto_definitions()
|
||||
docs = [d.docstring(raw=True) for d in defs]
|
||||
docs = [d.docstring() for d in defs]
|
||||
self.assertEqual(docs, ['Original docstring.', 'Docstring of `x`.'])
|
||||
|
||||
def test_completion(self):
|
||||
@@ -105,6 +120,10 @@ class TestDocstring(unittest.TestCase):
|
||||
assert '__init__' in names
|
||||
assert 'mro' not in names # Exists only for types.
|
||||
|
||||
def test_docstring_keyword(self):
|
||||
completions = jedi.Script('assert').completions()
|
||||
self.assertIn('assert', completions[0].docstring())
|
||||
|
||||
@unittest.skipIf(numpydoc_unavailable, 'numpydoc module is unavailable')
|
||||
def test_numpydoc_docstring(self):
|
||||
s = dedent('''
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from jedi._compatibility import is_py3
|
||||
from jedi import parser_utils
|
||||
from parso import parse
|
||||
|
||||
Reference in New Issue
Block a user