test: Add *args and **kwargs to testcase of target.typehints

This commit is contained in:
Takeshi KOMIYA 2022-05-15 19:05:17 +09:00
parent 23ab36bcd7
commit 92fcac321b
2 changed files with 29 additions and 11 deletions

View File

@ -94,8 +94,10 @@ def missing_attr(c,
class _ClassWithDocumentedInit:
"""Class docstring."""
def __init__(self, x: int) -> None:
def __init__(self, x: int, *args: int, **kwargs: int) -> None:
"""Init docstring.
:param x: Some integer
:param args: Some integer
:param kwargs: Some integer
"""

View File

@ -1034,22 +1034,30 @@ def test_autodoc_typehints_description_with_documented_init(app):
)
app.build()
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
assert ('class target.typehints._ClassWithDocumentedInit(x)\n'
assert ('class target.typehints._ClassWithDocumentedInit(x, *args, **kwargs)\n'
'\n'
' Class docstring.\n'
'\n'
' Parameters:\n'
' **x** (*int*) --\n'
' * **x** (*int*) --\n'
'\n'
' * **args** (*int*) --\n'
'\n'
' * **kwargs** (*int*) --\n'
'\n'
' Return type:\n'
' None\n'
'\n'
' __init__(x)\n'
' __init__(x, *args, **kwargs)\n'
'\n'
' Init docstring.\n'
'\n'
' Parameters:\n'
' **x** (*int*) -- Some integer\n'
' * **x** (*int*) -- Some integer\n'
'\n'
' * **args** (*int*) -- Some integer\n'
'\n'
' * **kwargs** (*int*) -- Some integer\n'
'\n'
' Return type:\n'
' None\n' == context)
@ -1066,16 +1074,20 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc(app):
)
app.build()
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
assert ('class target.typehints._ClassWithDocumentedInit(x)\n'
assert ('class target.typehints._ClassWithDocumentedInit(x, *args, **kwargs)\n'
'\n'
' Class docstring.\n'
'\n'
' __init__(x)\n'
' __init__(x, *args, **kwargs)\n'
'\n'
' Init docstring.\n'
'\n'
' Parameters:\n'
' **x** (*int*) -- Some integer\n' == context)
' * **x** (*int*) -- Some integer\n'
'\n'
' * **args** (*int*) -- Some integer\n'
'\n'
' * **kwargs** (*int*) -- Some integer\n' == context)
@pytest.mark.sphinx('text', testroot='ext-autodoc',
@ -1092,16 +1104,20 @@ def test_autodoc_typehints_description_with_documented_init_no_undoc_doc_rtype(a
)
app.build()
context = (app.outdir / 'index.txt').read_text(encoding='utf8')
assert ('class target.typehints._ClassWithDocumentedInit(x)\n'
assert ('class target.typehints._ClassWithDocumentedInit(x, *args, **kwargs)\n'
'\n'
' Class docstring.\n'
'\n'
' __init__(x)\n'
' __init__(x, *args, **kwargs)\n'
'\n'
' Init docstring.\n'
'\n'
' Parameters:\n'
' **x** (*int*) -- Some integer\n' == context)
' * **x** (*int*) -- Some integer\n'
'\n'
' * **args** (*int*) -- Some integer\n'
'\n'
' * **kwargs** (*int*) -- Some integer\n' == context)
@pytest.mark.sphinx('text', testroot='ext-autodoc',