From 7906a6871ecf1e4b0cdfc73fb3ac35bd2bb3719d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 17 Jan 2020 09:11:59 +0900 Subject: [PATCH] Add testcase a partialmethod not having docstring (refs: #7023) --- .../test-ext-autodoc/target/partialmethod.py | 2 +- tests/test_autodoc.py | 41 ++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/tests/roots/test-ext-autodoc/target/partialmethod.py b/tests/roots/test-ext-autodoc/target/partialmethod.py index 01cf4e798..4966a984f 100644 --- a/tests/roots/test-ext-autodoc/target/partialmethod.py +++ b/tests/roots/test-ext-autodoc/target/partialmethod.py @@ -14,5 +14,5 @@ class Cell(object): #: Make a cell alive. set_alive = partialmethod(set_state, True) + # a partialmethod with no docstring set_dead = partialmethod(set_state, False) - """Make a cell dead.""" diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index bd13cf6c2..6de2233d1 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -1324,12 +1324,6 @@ def test_partialmethod(app): ' Make a cell alive.', ' ', ' ', - ' .. py:method:: Cell.set_dead()', - ' :module: target.partialmethod', - ' ', - ' Make a cell dead.', - ' ', - ' ', ' .. py:method:: Cell.set_state(state)', ' :module: target.partialmethod', ' ', @@ -1342,6 +1336,41 @@ def test_partialmethod(app): assert list(actual) == expected +@pytest.mark.sphinx('html', testroot='ext-autodoc') +def test_partialmethod_undoc_members(app): + expected = [ + '', + '.. py:class:: Cell', + ' :module: target.partialmethod', + '', + ' An example for partialmethod.', + ' ', + ' refs: https://docs.python.jp/3/library/functools.html#functools.partialmethod', + ' ', + ' ', + ' .. py:method:: Cell.set_alive()', + ' :module: target.partialmethod', + ' ', + ' Make a cell alive.', + ' ', + ' ', + ' .. py:method:: Cell.set_dead()', + ' :module: target.partialmethod', + ' ', + ' ', + ' .. py:method:: Cell.set_state(state)', + ' :module: target.partialmethod', + ' ', + ' Update state of cell to *state*.', + ' ', + ] + + options = {"members": None, + "undoc-members": None} + actual = do_autodoc(app, 'class', 'target.partialmethod.Cell', options) + assert list(actual) == expected + + @pytest.mark.sphinx('html', testroot='pycode-egg') def test_autodoc_for_egged_code(app): options = {"members": None,