test for #178, docstring type annotations should be executed

This commit is contained in:
Dave Halter
2014-04-02 20:41:25 +02:00
parent 28fbdbc0f6
commit e681ed9fda

View File

@@ -2,6 +2,7 @@
Testing of docstring related issues and especially ``jedi.docstrings``.
"""
from textwrap import dedent
import jedi
from ..helpers import unittest
@@ -59,3 +60,30 @@ class TestDocstring(unittest.TestCase):
names = [c.name for c in jedi.Script(s).completions()]
assert 'join' in names
def test_docstring_instance(self):
# The types hint that it's a certain kind
s = dedent("""
class A:
def __init__(self,a):
'''
:type a: threading.Thread
'''
if a is not None:
a.start()
self.a = a
def method_b(c):
'''
:type c: A
'''
c.""")
names = [c.name for c in jedi.Script(s).completions()]
assert 'a' in names
assert '__init__' in names
assert 'mro' not in names # Exists only for types.