summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-ext-autodoc/target/inheritance.py3
-rw-r--r--tests/test_ext_autodoc.py8
-rw-r--r--tests/test_ext_autodoc_automodule.py7
-rw-r--r--tests/test_ext_autodoc_configs.py66
4 files changed, 84 insertions, 0 deletions
diff --git a/tests/roots/test-ext-autodoc/target/inheritance.py b/tests/roots/test-ext-autodoc/target/inheritance.py
index 485a943c8..85d95cd74 100644
--- a/tests/roots/test-ext-autodoc/target/inheritance.py
+++ b/tests/roots/test-ext-autodoc/target/inheritance.py
@@ -1,4 +1,7 @@
class Base(object):
+ #: docstring
+ inheritedattr = None
+
def inheritedmeth(self):
"""Inherited function."""
diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py
index ecd2bbce6..a35c6f640 100644
--- a/tests/test_ext_autodoc.py
+++ b/tests/test_ext_autodoc.py
@@ -549,6 +549,7 @@ def test_autodoc_members(app):
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
+ ' .. py:attribute:: Base.inheritedattr',
' .. py:method:: Base.inheritedclassmeth()',
' .. py:method:: Base.inheritedmeth()',
' .. py:method:: Base.inheritedstaticmeth(cls)'
@@ -569,6 +570,7 @@ def test_autodoc_members(app):
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
+ ' .. py:attribute:: Base.inheritedattr',
' .. py:method:: Base.inheritedclassmeth()',
' .. py:method:: Base.inheritedmeth()',
' .. py:method:: Base.inheritedstaticmeth(cls)'
@@ -601,6 +603,7 @@ def test_autodoc_exclude_members(app):
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
+ ' .. py:attribute:: Base.inheritedattr',
' .. py:method:: Base.inheritedclassmeth()'
]
@@ -618,6 +621,7 @@ def test_autodoc_exclude_members(app):
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
+ ' .. py:attribute:: Base.inheritedattr',
' .. py:method:: Base.inheritedclassmeth()'
]
@@ -628,6 +632,7 @@ def test_autodoc_exclude_members(app):
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
+ ' .. py:attribute:: Base.inheritedattr',
' .. py:method:: Base.inheritedclassmeth()',
' .. py:method:: Base.inheritedstaticmeth(cls)'
]
@@ -639,6 +644,7 @@ def test_autodoc_exclude_members(app):
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
+ ' .. py:attribute:: Base.inheritedattr',
' .. py:method:: Base.inheritedclassmeth()',
]
@@ -648,6 +654,7 @@ def test_autodoc_exclude_members(app):
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
+ ' .. py:attribute:: Base.inheritedattr',
' .. py:method:: Base.inheritedclassmeth()',
]
@@ -658,6 +665,7 @@ def test_autodoc_exclude_members(app):
actual = do_autodoc(app, 'class', 'target.inheritance.Base', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Base()',
+ ' .. py:attribute:: Base.inheritedattr',
' .. py:method:: Base.inheritedclassmeth()',
' .. py:method:: Base.inheritedmeth()',
' .. py:method:: Base.inheritedstaticmeth(cls)'
diff --git a/tests/test_ext_autodoc_automodule.py b/tests/test_ext_autodoc_automodule.py
index 8208d86f6..71b23679d 100644
--- a/tests/test_ext_autodoc_automodule.py
+++ b/tests/test_ext_autodoc_automodule.py
@@ -133,6 +133,13 @@ def test_automodule_inherited_members(app):
' :module: target.inheritance',
'',
'',
+ ' .. py:attribute:: Base.inheritedattr',
+ ' :module: target.inheritance',
+ ' :value: None',
+ '',
+ ' docstring',
+ '',
+ '',
' .. py:method:: Base.inheritedclassmeth()',
' :module: target.inheritance',
' :classmethod:',
diff --git a/tests/test_ext_autodoc_configs.py b/tests/test_ext_autodoc_configs.py
index 0011f450b..f40f3354e 100644
--- a/tests/test_ext_autodoc_configs.py
+++ b/tests/test_ext_autodoc_configs.py
@@ -278,6 +278,72 @@ def test_autodoc_inherit_docstrings(app):
@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_autodoc_inherit_docstrings_for_inherited_members(app):
+ options = {"members": None,
+ "inherited-members": None}
+
+ assert app.config.autodoc_inherit_docstrings is True # default
+ actual = do_autodoc(app, 'class', 'target.inheritance.Derived', options)
+ assert list(actual) == [
+ '',
+ '.. py:class:: Derived()',
+ ' :module: target.inheritance',
+ '',
+ '',
+ ' .. py:attribute:: Derived.inheritedattr',
+ ' :module: target.inheritance',
+ ' :value: None',
+ '',
+ ' docstring',
+ '',
+ '',
+ ' .. py:method:: Derived.inheritedclassmeth()',
+ ' :module: target.inheritance',
+ ' :classmethod:',
+ '',
+ ' Inherited class method.',
+ '',
+ '',
+ ' .. py:method:: Derived.inheritedmeth()',
+ ' :module: target.inheritance',
+ '',
+ ' Inherited function.',
+ '',
+ '',
+ ' .. py:method:: Derived.inheritedstaticmeth(cls)',
+ ' :module: target.inheritance',
+ ' :staticmethod:',
+ '',
+ ' Inherited static method.',
+ '',
+ ]
+
+ # disable autodoc_inherit_docstrings
+ app.config.autodoc_inherit_docstrings = False
+ actual = do_autodoc(app, 'class', 'target.inheritance.Derived', options)
+ assert list(actual) == [
+ '',
+ '.. py:class:: Derived()',
+ ' :module: target.inheritance',
+ '',
+ '',
+ ' .. py:method:: Derived.inheritedclassmeth()',
+ ' :module: target.inheritance',
+ ' :classmethod:',
+ '',
+ ' Inherited class method.',
+ '',
+ '',
+ ' .. py:method:: Derived.inheritedstaticmeth(cls)',
+ ' :module: target.inheritance',
+ ' :staticmethod:',
+ '',
+ ' Inherited static method.',
+ '',
+ ]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_docstring_signature(app):
options = {"members": None, "special-members": "__init__, __new__"}
actual = do_autodoc(app, 'class', 'target.DocstringSig', options)