From e681ed9fdade79ab50f546298e8d039e3480a5dc Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 2 Apr 2014 20:41:25 +0200 Subject: [PATCH] test for #178, docstring type annotations should be executed --- test/test_evaluate/test_docstring.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/test_evaluate/test_docstring.py b/test/test_evaluate/test_docstring.py index 7ec0f596..daa2d331 100644 --- a/test/test_evaluate/test_docstring.py +++ b/test/test_evaluate/test_docstring.py @@ -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.