summaryrefslogtreecommitdiffstats
path: root/tests/test_extensions/test_ext_autodoc_autoclass.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/test_extensions/test_ext_autodoc_autoclass.py (renamed from tests/test_ext_autodoc_autoclass.py)55
1 files changed, 52 insertions, 3 deletions
diff --git a/tests/test_ext_autodoc_autoclass.py b/tests/test_extensions/test_ext_autodoc_autoclass.py
index 92c259a..3e68d60 100644
--- a/tests/test_ext_autodoc_autoclass.py
+++ b/tests/test_extensions/test_ext_autodoc_autoclass.py
@@ -11,7 +11,7 @@ from typing import Union
import pytest
-from .test_ext_autodoc import do_autodoc
+from tests.test_extensions.autodoc_util import do_autodoc
@pytest.mark.sphinx('html', testroot='ext-autodoc')
@@ -169,6 +169,7 @@ def test_undocumented_uninitialized_attributes(app):
]
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_decorators(app):
actual = do_autodoc(app, 'class', 'target.decorator.Baz')
assert list(actual) == [
@@ -275,8 +276,7 @@ def test_show_inheritance_for_subclass_of_generic_type(app):
'.. py:class:: Quux(iterable=(), /)',
' :module: target.classes',
'',
- ' Bases: :py:class:`~typing.List`\\ '
- '[:py:obj:`~typing.Union`\\ [:py:class:`int`, :py:class:`float`]]',
+ ' Bases: :py:class:`~typing.List`\\ [:py:class:`int` | :py:class:`float`]',
'',
' A subclass of List[Union[int, float]]',
'',
@@ -373,6 +373,7 @@ def test_class_doc_from_both(app):
]
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_class_alias(app):
def autodoc_process_docstring(*args):
"""A handler always raises an error.
@@ -391,6 +392,7 @@ def test_class_alias(app):
]
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_class_alias_having_doccomment(app):
actual = do_autodoc(app, 'class', 'target.classes.OtherAlias')
assert list(actual) == [
@@ -403,6 +405,7 @@ def test_class_alias_having_doccomment(app):
]
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_class_alias_for_imported_object_having_doccomment(app):
actual = do_autodoc(app, 'class', 'target.classes.IntAlias')
assert list(actual) == [
@@ -515,3 +518,49 @@ def test_autoattribute_TypeVar_module_level(app):
" alias of TypeVar('T1')",
'',
]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_inherited_instance_variable_with_annotations(app):
+ options = {'members': None,
+ 'inherited-members': None}
+ actual = do_autodoc(app, 'class', 'target.inherited_annotations.NoTypeAnnotation', options)
+ assert list(actual) == [
+ '',
+ '.. py:class:: NoTypeAnnotation()',
+ ' :module: target.inherited_annotations',
+ '',
+ '',
+ ' .. py:attribute:: NoTypeAnnotation.a',
+ ' :module: target.inherited_annotations',
+ ' :value: 1',
+ '',
+ ' Local',
+ '',
+ '',
+ ' .. py:attribute:: NoTypeAnnotation.inherit_me',
+ ' :module: target.inherited_annotations',
+ ' :type: int',
+ '',
+ ' Inherited',
+ '',
+ ]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_no_inherited_instance_variable_with_annotations(app):
+ options = {'members': None}
+ actual = do_autodoc(app, 'class', 'target.inherited_annotations.NoTypeAnnotation2', options)
+ assert list(actual) == [
+ '',
+ '.. py:class:: NoTypeAnnotation2()',
+ ' :module: target.inherited_annotations',
+ '',
+ '',
+ ' .. py:attribute:: NoTypeAnnotation2.a',
+ ' :module: target.inherited_annotations',
+ ' :value: 1',
+ '',
+ ' Local',
+ '',
+ ]