mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
test: Add *args and **kwargs to testcase of target.typehints
This commit is contained in:
parent
23ab36bcd7
commit
92fcac321b
@ -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
|
||||
"""
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user