Make sure that include_signature always works, fixes #1466

This commit is contained in:
Dave Halter
2020-01-01 15:13:53 +01:00
parent 8e2bfdc07e
commit 8770e12d16
4 changed files with 44 additions and 15 deletions

View File

@@ -2,11 +2,14 @@
Testing of docstring related issues and especially ``jedi.docstrings``.
"""
from textwrap import dedent
import jedi
import pytest
from ..helpers import unittest
import os
import sys
from textwrap import dedent
import pytest
import jedi
from ..helpers import unittest, test_dir
try:
import numpydoc # NOQA
@@ -171,6 +174,22 @@ def test_docstring_params_formatting(Script):
assert defs[0].docstring() == 'func(param1, param2, param3)'
def test_import_function_docstring(Script, skip_pre_python35):
code = "from stub_folder import with_stub; with_stub.stub_function"
path = os.path.join(test_dir, 'completion', 'import_function_docstring.py')
c, = Script(code, path=path).complete()
stub_signature = 'stub_function(x: int, y: float) -> str'
python_signature = 'stub_function(x: float, y)'
doc = '\n\nPython docstring'
assert c.docstring() == stub_signature + doc
assert c.type == 'function'
func, = c.goto(prefer_stubs=True)
assert func.docstring() == stub_signature + doc
func, = c.goto()
assert func.docstring() == python_signature + doc
# ---- Numpy Style Tests ---
@pytest.mark.skipif(numpydoc_unavailable,