Basic test for docstring inheritance

This commit is contained in:
Antonio Valentino 2017-08-19 21:52:30 +02:00
parent 5148d6953b
commit 96ee24d7c1

View File

@ -431,6 +431,13 @@ def test_get_doc():
directive.env.config.autoclass_content = 'both'
assert getdocl('class', I) == ['Class docstring', '', 'New docstring']
# 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.usefixtures('setup_test')
def test_docstring_processing():
@ -941,6 +948,12 @@ class Base(object):
"""Inherited function."""
class Derived(Base):
def inheritedmeth(self):
# no docstring here
pass
class Class(Base):
"""Class to document."""