add testcase for complex typehintsext.autodoc.typehints

This commit is contained in:
Kjell Braden 2020-05-02 08:57:54 +02:00 committed by Takeshi KOMIYA
parent 4877a7594c
commit db72c18cf9
3 changed files with 28 additions and 2 deletions

View File

@ -9,3 +9,5 @@
:members: :members:
.. autofunction:: target.typehints.incr .. autofunction:: target.typehints.incr
.. autofunction:: target.typehints.tuple_args

View File

@ -1,3 +1,6 @@
from typing import Tuple, Union
def incr(a: int, b: int = 1) -> int: def incr(a: int, b: int = 1) -> int:
return a + b return a + b
@ -30,6 +33,10 @@ class Math:
return return
def tuple_args(x: Tuple[int, Union[int, str]]) -> Tuple[int, int]:
pass
def complex_func(arg1, arg2, arg3=None, *args, **kwargs): def complex_func(arg1, arg2, arg3=None, *args, **kwargs):
# type: (str, List[int], Tuple[int, Union[str, Unknown]], *str, **str) -> None # type: (str, List[int], Tuple[int, Union[str, Unknown]], *str, **str) -> None
pass pass

View File

@ -508,7 +508,11 @@ def test_autodoc_typehints_signature(app):
'', '',
'.. py:function:: missing_attr(c, a: str, b: Optional[str] = None) -> str', '.. py:function:: missing_attr(c, a: str, b: Optional[str] = None) -> str',
' :module: target.typehints', ' :module: target.typehints',
'' '',
'',
'.. py:function:: tuple_args(x: Tuple[int, Union[int, str]]) -> Tuple[int, int]',
' :module: target.typehints',
'',
] ]
@ -557,7 +561,11 @@ def test_autodoc_typehints_none(app):
'', '',
'.. py:function:: missing_attr(c, a, b=None)', '.. py:function:: missing_attr(c, a, b=None)',
' :module: target.typehints', ' :module: target.typehints',
'' '',
'',
'.. py:function:: tuple_args(x)',
' :module: target.typehints',
'',
] ]
@ -576,6 +584,15 @@ def test_autodoc_typehints_description(app):
' Return type:\n' ' Return type:\n'
' int\n' ' int\n'
in context) in context)
assert ('target.typehints.tuple_args(x)\n'
'\n'
' Parameters:\n'
' **x** (*Tuple**[**int**, **Union**[**int**, **str**]**]*) --\n'
'\n'
' Return type:\n'
' Tuple[int, int]\n'
in context)
@pytest.mark.sphinx('html', testroot='ext-autodoc') @pytest.mark.sphinx('html', testroot='ext-autodoc')