mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-11-02 20:30:30 -06:00
test: Update testcase for autodoc_inherit_docstrings
This commit is contained in:
1 parent
42e9fd896e
commit
f4114bb794
2 files changed
+24
-9
No files matched your search
@@ -454,15 +454,6 @@ def test_get_doc():
|
|||||||
assert getdocl('method', J.foo) == ['Method docstring']
|
assert getdocl('method', J.foo) == ['Method docstring']
|
||||||
assert getdocl('function', 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')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_new_documenter(app):
|
def test_new_documenter(app):
|
||||||
|
|||||||
@@ -18,6 +18,30 @@ from test_autodoc import do_autodoc
|
|||||||
IS_PYPY = platform.python_implementation() == 'PyPy'
|
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')
|
@pytest.mark.sphinx('html', testroot='ext-autodoc')
|
||||||
def test_autodoc_docstring_signature(app):
|
def test_autodoc_docstring_signature(app):
|
||||||
options = {"members": None}
|
options = {"members": None}
|
||||||
|
|||||||
Reference in new issue
Block a user