Fix some warnings.

This commit is contained in:
Dave Halter
2017-05-25 12:24:12 -04:00
parent 6a320147ac
commit ef2e2f343e
7 changed files with 20 additions and 16 deletions

View File

@@ -425,7 +425,7 @@ def defined_names(source, path=None, encoding='utf-8'):
Use :func:`names` instead.
.. todo:: Remove!
"""
warnings.warn("Use call_signatures instead.", DeprecationWarning)
warnings.warn("Use names instead.", DeprecationWarning)
return names(source, path, encoding)

View File

@@ -1,5 +1,6 @@
from textwrap import dedent
import inspect
import warnings
from ..helpers import TestCase
from jedi import Script
@@ -267,6 +268,9 @@ def test_signature_is_definition():
dont_scan = ['defined_names', 'parent', 'goto_assignments', 'params']
if attr_name.startswith('_') or attr_name in dont_scan:
continue
# Might trigger some deprecation warnings.
with warnings.catch_warnings(record=True):
attribute = getattr(definition, attr_name)
signature_attribute = getattr(signature, attr_name)
if inspect.ismethod(attribute):

View File

@@ -94,7 +94,7 @@ def test_function_call_signature_in_doc():
def f(x, y=1, z='a'):
pass
f""").goto_definitions()
doc = defs[0].doc
doc = defs[0].docstring()
assert "f(x, y=1, z='a')" in str(doc)
@@ -104,7 +104,7 @@ def test_class_call_signature():
def __init__(self, x, y=1, z='a'):
pass
Foo""").goto_definitions()
doc = defs[0].doc
doc = defs[0].docstring()
assert "Foo(self, x, y=1, z='a')" in str(doc)

View File

@@ -4,7 +4,7 @@ Tests for `api.defined_names`.
from textwrap import dedent
from jedi import defined_names, names
from jedi import names
from ..helpers import TestCase
@@ -76,7 +76,7 @@ class TestDefinedNames(TestCase):
def test_follow_imports():
# github issue #344
imp = defined_names('import datetime')[0]
imp = names('import datetime')[0]
assert imp.name == 'datetime'
datetime_names = [str(d.name) for d in imp.defined_names()]
assert 'timedelta' in datetime_names

View File

@@ -61,7 +61,7 @@ class TestFullDefinedName(TestCase):
"""
def check(self, source, desired):
definitions = jedi.defined_names(textwrap.dedent(source))
definitions = jedi.names(textwrap.dedent(source))
full_names = [d.full_name for d in definitions]
self.assertEqual(full_names, desired)

View File

@@ -20,7 +20,7 @@ class TestDocstring(unittest.TestCase):
def func():
'''Docstring of `func`.'''
func""").goto_definitions()
self.assertEqual(defs[0].raw_doc, 'Docstring of `func`.')
self.assertEqual(defs[0].docstring(raw=True), 'Docstring of `func`.')
@unittest.skip('need evaluator class for that')
def test_attribute_docstring(self):
@@ -28,7 +28,7 @@ class TestDocstring(unittest.TestCase):
x = None
'''Docstring of `x`.'''
x""").goto_definitions()
self.assertEqual(defs[0].raw_doc, 'Docstring of `x`.')
self.assertEqual(defs[0].docstring(raw=True), 'Docstring of `x`.')
@unittest.skip('need evaluator class for that')
def test_multiple_docstrings(self):
@@ -38,7 +38,7 @@ class TestDocstring(unittest.TestCase):
x = func
'''Docstring of `x`.'''
x""").goto_definitions()
docs = [d.raw_doc for d in defs]
docs = [d.docstring(raw=True) for d in defs]
self.assertEqual(docs, ['Original docstring.', 'Docstring of `x`.'])
def test_completion(self):

View File

@@ -18,7 +18,7 @@ def test_keyword():
""" github jedi-vim issue #44 """
defs = Script("print").goto_definitions()
if is_py3:
assert [d.doc for d in defs]
assert [d.docstring() for d in defs]
else:
assert defs == []