From 92fcac321be6598e22877465b3d60730aa24f1f1 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 15 May 2022 19:05:17 +0900 Subject: [PATCH] test: Add *args and **kwargs to testcase of target.typehints --- .../test-ext-autodoc/target/typehints.py | 4 ++- tests/test_ext_autodoc_configs.py | 36 +++++++++++++------ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/tests/roots/test-ext-autodoc/target/typehints.py b/tests/roots/test-ext-autodoc/target/typehints.py index 6b0d6142c..4acfc8911 100644 --- a/tests/roots/test-ext-autodoc/target/typehints.py +++ b/tests/roots/test-ext-autodoc/target/typehints.py @@ -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 """ diff --git a/tests/test_ext_autodoc_configs.py b/tests/test_ext_autodoc_configs.py index fdb82b1b9..12ec0e022 100644 --- a/tests/test_ext_autodoc_configs.py +++ b/tests/test_ext_autodoc_configs.py @@ -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',