summaryrefslogtreecommitdiff
path: root/tests/test_ext_autodoc_autoclass.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-05-03 22:33:12 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-05-03 22:33:12 +0900
commit3027a2f8675e6140f2d8b83d19bec4159a09af5c (patch)
treed4db4de45fe517f165425014dd1d90fc9bb6816e /tests/test_ext_autodoc_autoclass.py
parentf5e7b9b815977790f940ffcc374550bb70fc99d4 (diff)
parentf31af4b8158e6142d918366aa0026e40575af914 (diff)
downloadsphinx-git-3027a2f8675e6140f2d8b83d19bec4159a09af5c.tar.gz
Merge branch '4.x'
Diffstat (limited to 'tests/test_ext_autodoc_autoclass.py')
-rw-r--r--tests/test_ext_autodoc_autoclass.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/test_ext_autodoc_autoclass.py b/tests/test_ext_autodoc_autoclass.py
index d879f8e14..096dc9397 100644
--- a/tests/test_ext_autodoc_autoclass.py
+++ b/tests/test_ext_autodoc_autoclass.py
@@ -264,6 +264,53 @@ def test_show_inheritance_for_subclass_of_generic_type(app):
]
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_class_doc_from_class(app):
+ options = {"members": None,
+ "class-doc-from": "class"}
+ actual = do_autodoc(app, 'class', 'target.autoclass_content.C', options)
+ assert list(actual) == [
+ '',
+ '.. py:class:: C()',
+ ' :module: target.autoclass_content',
+ '',
+ ' A class having __init__, no __new__',
+ '',
+ ]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_class_doc_from_init(app):
+ options = {"members": None,
+ "class-doc-from": "init"}
+ actual = do_autodoc(app, 'class', 'target.autoclass_content.C', options)
+ assert list(actual) == [
+ '',
+ '.. py:class:: C()',
+ ' :module: target.autoclass_content',
+ '',
+ ' __init__ docstring',
+ '',
+ ]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_class_doc_from_both(app):
+ options = {"members": None,
+ "class-doc-from": "both"}
+ actual = do_autodoc(app, 'class', 'target.autoclass_content.C', options)
+ assert list(actual) == [
+ '',
+ '.. py:class:: C()',
+ ' :module: target.autoclass_content',
+ '',
+ ' A class having __init__, no __new__',
+ '',
+ ' __init__ docstring',
+ '',
+ ]
+
+
def test_class_alias(app):
def autodoc_process_docstring(*args):
"""A handler always raises an error.