mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
test: Update testcase for autodoc_inherit_docstrings
This commit is contained in:
@@ -454,15 +454,6 @@ def test_get_doc():
|
||||
assert getdocl('method', J.foo) == ['Method docstring']
|
||||
assert getdocl('function', J().foo) == ['Method docstring']
|
||||
|
||||
from target.inheritance import Base, Derived
|
||||
|
||||
# NOTE: inspect.getdoc seems not to work with locally defined classes
|
||||
directive.env.config.autodoc_inherit_docstrings = False
|
||||
assert getdocl('method', Base.inheritedmeth) == ['Inherited function.']
|
||||
assert getdocl('method', Derived.inheritedmeth) == []
|
||||
directive.env.config.autodoc_inherit_docstrings = True
|
||||
assert getdocl('method', Derived.inheritedmeth) == ['Inherited function.']
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_new_documenter(app):
|
||||
|
@@ -18,6 +18,30 @@ from test_autodoc import do_autodoc
|
||||
IS_PYPY = platform.python_implementation() == 'PyPy'
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_inherit_docstrings(app):
|
||||
assert app.config.autodoc_inherit_docstrings is True # default
|
||||
actual = do_autodoc(app, 'method', 'target.inheritance.Derived.inheritedmeth')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:method:: Derived.inheritedmeth()',
|
||||
' :module: target.inheritance',
|
||||
'',
|
||||
' Inherited function.',
|
||||
' '
|
||||
]
|
||||
|
||||
# disable autodoc_inherit_docstrings
|
||||
app.config.autodoc_inherit_docstrings = False
|
||||
actual = do_autodoc(app, 'method', 'target.inheritance.Derived.inheritedmeth')
|
||||
assert list(actual) == [
|
||||
'',
|
||||
'.. py:method:: Derived.inheritedmeth()',
|
||||
' :module: target.inheritance',
|
||||
''
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||
def test_autodoc_docstring_signature(app):
|
||||
options = {"members": None}
|
||||
|
Reference in New Issue
Block a user