diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-02-14 14:45:25 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2016-02-14 14:45:25 +0900 |
commit | dca1669b2fc38468cda6038dd4f79768936a4036 (patch) | |
tree | 84cf597501bc1fbe3bd4c5f694912cbbfe96c1cb /tests/test_autodoc.py | |
parent | fed5a345688ff1c2bc0887d6202b46224af25f0b (diff) | |
parent | 0311f33347d7c49613f3249ecaa6028f1eddeef8 (diff) | |
download | sphinx-git-dca1669b2fc38468cda6038dd4f79768936a4036.tar.gz |
Merge pull request #2300 from akruis/feature_autoclass_content_from__new__
Feature: enhance autoclass:: to use the docstring of __new__ if __init__ method's is missing of empty
Diffstat (limited to 'tests/test_autodoc.py')
-rw-r--r-- | tests/test_autodoc.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 2542a3faa..183484846 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -297,6 +297,9 @@ def test_get_doc(): """Class docstring""" def __init__(self): """Init docstring""" + + def __new__(cls): + """New docstring""" directive.env.config.autoclass_content = 'class' assert getdocl('class', C) == ['Class docstring'] directive.env.config.autoclass_content = 'init' @@ -380,6 +383,36 @@ def test_get_doc(): directive.env.config.autoclass_content = 'both' assert getdocl('class', G) == ['Class docstring'] + # class has __new__ method with docstring + # class docstring: depends on config value which one is taken + class H: + """Class docstring""" + def __init__(self): + pass + + def __new__(cls): + """New docstring""" + directive.env.config.autoclass_content = 'class' + assert getdocl('class', H) == ['Class docstring'] + directive.env.config.autoclass_content = 'init' + assert getdocl('class', H) == ['New docstring'] + directive.env.config.autoclass_content = 'both' + assert getdocl('class', H) == ['Class docstring', '', 'New docstring'] + + # class has __init__ method without docstring and + # __new__ method with docstring + # class docstring: depends on config value which one is taken + class I: + """Class docstring""" + def __new__(cls): + """New docstring""" + directive.env.config.autoclass_content = 'class' + assert getdocl('class', I) == ['Class docstring'] + directive.env.config.autoclass_content = 'init' + assert getdocl('class', I) == ['New docstring'] + directive.env.config.autoclass_content = 'both' + assert getdocl('class', I) == ['Class docstring', '', 'New docstring'] + @with_setup(setup_test) def test_docstring_processing(): |