forked from VimPlug/jedi
Fix some warnings.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from textwrap import dedent
|
||||
import inspect
|
||||
import warnings
|
||||
|
||||
from ..helpers import TestCase
|
||||
from jedi import Script
|
||||
@@ -267,12 +268,15 @@ def test_signature_is_definition():
|
||||
dont_scan = ['defined_names', 'parent', 'goto_assignments', 'params']
|
||||
if attr_name.startswith('_') or attr_name in dont_scan:
|
||||
continue
|
||||
attribute = getattr(definition, attr_name)
|
||||
signature_attribute = getattr(signature, attr_name)
|
||||
if inspect.ismethod(attribute):
|
||||
assert attribute() == signature_attribute()
|
||||
else:
|
||||
assert attribute == signature_attribute
|
||||
|
||||
# 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):
|
||||
assert attribute() == signature_attribute()
|
||||
else:
|
||||
assert attribute == signature_attribute
|
||||
|
||||
|
||||
def test_no_signature():
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user