summaryrefslogtreecommitdiffstats
path: root/tests/test_extensions/test_ext_autodoc_configs.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/test_extensions/test_ext_autodoc_configs.py (renamed from tests/test_ext_autodoc_configs.py)48
1 files changed, 32 insertions, 16 deletions
diff --git a/tests/test_ext_autodoc_configs.py b/tests/test_extensions/test_ext_autodoc_configs.py
index 45bc729..6c2af5a 100644
--- a/tests/test_ext_autodoc_configs.py
+++ b/tests/test_extensions/test_ext_autodoc_configs.py
@@ -8,7 +8,7 @@ import pytest
from sphinx.testing import restructuredtext
-from .test_ext_autodoc import do_autodoc
+from tests.test_extensions.autodoc_util import do_autodoc
IS_PYPY = platform.python_implementation() == 'PyPy'
@@ -969,9 +969,9 @@ def test_autodoc_typehints_description(app):
assert ('target.typehints.incr(a, b=1)\n'
'\n'
' Parameters:\n'
- ' * **a** (*int*) --\n'
+ ' * **a** (*int*)\n'
'\n'
- ' * **b** (*int*) --\n'
+ ' * **b** (*int*)\n'
'\n'
' Return type:\n'
' int\n'
@@ -979,7 +979,7 @@ def test_autodoc_typehints_description(app):
assert ('target.typehints.tuple_args(x)\n'
'\n'
' Parameters:\n'
- ' **x** (*tuple**[**int**, **int** | **str**]*) --\n'
+ ' **x** (*tuple**[**int**, **int** | **str**]*)\n'
'\n'
' Return type:\n'
' tuple[int, int]\n'
@@ -1117,11 +1117,11 @@ def test_autodoc_typehints_description_with_documented_init(app):
' Class docstring.\n'
'\n'
' Parameters:\n'
- ' * **x** (*int*) --\n'
+ ' * **x** (*int*)\n'
'\n'
- ' * **args** (*int*) --\n'
+ ' * **args** (*int*)\n'
'\n'
- ' * **kwargs** (*int*) --\n'
+ ' * **kwargs** (*int*)\n'
'\n'
' __init__(x, *args, **kwargs)\n'
'\n'
@@ -1217,9 +1217,9 @@ def test_autodoc_typehints_both(app):
assert ('target.typehints.incr(a: int, b: int = 1) -> int\n'
'\n'
' Parameters:\n'
- ' * **a** (*int*) --\n'
+ ' * **a** (*int*)\n'
'\n'
- ' * **b** (*int*) --\n'
+ ' * **b** (*int*)\n'
'\n'
' Return type:\n'
' int\n'
@@ -1227,7 +1227,7 @@ def test_autodoc_typehints_both(app):
assert ('target.typehints.tuple_args(x: tuple[int, int | str]) -> tuple[int, int]\n'
'\n'
' Parameters:\n'
- ' **x** (*tuple**[**int**, **int** | **str**]*) --\n'
+ ' **x** (*tuple**[**int**, **int** | **str**]*)\n'
'\n'
' Return type:\n'
' tuple[int, int]\n'
@@ -1401,9 +1401,9 @@ def test_autodoc_typehints_description_and_type_aliases(app):
' docstring\n'
'\n'
' Parameters:\n'
- ' * **x** (*myint*) --\n'
+ ' * **x** (*myint*)\n'
'\n'
- ' * **y** (*myint*) --\n'
+ ' * **y** (*myint*)\n'
'\n'
' Return type:\n'
' myint\n'
@@ -1584,6 +1584,14 @@ def test_autodoc_typehints_format_fully_qualified_for_newtype_alias(app):
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_default_options(app):
+ if (
+ (3, 11, 7) <= sys.version_info < (3, 12)
+ or sys.version_info >= (3, 12, 1)
+ ):
+ list_of_weak_references = " list of weak references to the object"
+ else:
+ list_of_weak_references = " list of weak references to the object (if defined)"
+
# no settings
actual = do_autodoc(app, 'class', 'target.enums.EnumCls')
assert ' .. py:attribute:: EnumCls.val1' not in actual
@@ -1627,7 +1635,7 @@ def test_autodoc_default_options(app):
assert ' Iterate squares of each value.' in actual
if not IS_PYPY:
assert ' .. py:attribute:: CustomIter.__weakref__' in actual
- assert ' list of weak references to the object (if defined)' in actual
+ assert list_of_weak_references in actual
# :exclude-members: None - has no effect. Unlike :members:,
# :special-members:, etc. where None == "include all", here None means
@@ -1651,13 +1659,21 @@ def test_autodoc_default_options(app):
assert ' Iterate squares of each value.' in actual
if not IS_PYPY:
assert ' .. py:attribute:: CustomIter.__weakref__' in actual
- assert ' list of weak references to the object (if defined)' in actual
+ assert list_of_weak_references in actual
assert ' .. py:method:: CustomIter.snafucate()' in actual
assert ' Makes this snafucated.' in actual
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_default_options_with_values(app):
+ if (
+ (3, 11, 7) <= sys.version_info < (3, 12)
+ or sys.version_info >= (3, 12, 1)
+ ):
+ list_of_weak_references = " list of weak references to the object"
+ else:
+ list_of_weak_references = " list of weak references to the object (if defined)"
+
# with :members:
app.config.autodoc_default_options = {'members': 'val1,val2'}
actual = do_autodoc(app, 'class', 'target.enums.EnumCls')
@@ -1698,7 +1714,7 @@ def test_autodoc_default_options_with_values(app):
assert ' Iterate squares of each value.' in actual
if not IS_PYPY:
assert ' .. py:attribute:: CustomIter.__weakref__' not in actual
- assert ' list of weak references to the object (if defined)' not in actual
+ assert list_of_weak_references not in actual
# with :exclude-members:
app.config.autodoc_default_options = {
@@ -1722,6 +1738,6 @@ def test_autodoc_default_options_with_values(app):
assert ' Iterate squares of each value.' in actual
if not IS_PYPY:
assert ' .. py:attribute:: CustomIter.__weakref__' not in actual
- assert ' list of weak references to the object (if defined)' not in actual
+ assert list_of_weak_references not in actual
assert ' .. py:method:: CustomIter.snafucate()' not in actual
assert ' Makes this snafucated.' not in actual