summaryrefslogtreecommitdiffstats
path: root/tests/test_ext_autodoc_preserve_defaults.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 11:31:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 11:31:33 +0000
commite863fd965dd6253243c3342bd6f0adc4fc8aec4d (patch)
treea4c1b6491a82593950043c3f8b2530e80664d768 /tests/test_ext_autodoc_preserve_defaults.py
parentInitial commit. (diff)
downloadsphinx-e863fd965dd6253243c3342bd6f0adc4fc8aec4d.tar.xz
sphinx-e863fd965dd6253243c3342bd6f0adc4fc8aec4d.zip
Adding upstream version 5.3.0.upstream/5.3.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_ext_autodoc_preserve_defaults.py')
-rw-r--r--tests/test_ext_autodoc_preserve_defaults.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/test_ext_autodoc_preserve_defaults.py b/tests/test_ext_autodoc_preserve_defaults.py
new file mode 100644
index 0000000..ba5ff6e
--- /dev/null
+++ b/tests/test_ext_autodoc_preserve_defaults.py
@@ -0,0 +1,55 @@
+"""Test the autodoc extension."""
+
+import sys
+
+import pytest
+
+from .test_ext_autodoc import do_autodoc
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc',
+ confoverrides={'autodoc_preserve_defaults': True})
+def test_preserve_defaults(app):
+ if sys.version_info < (3, 8):
+ color = "16777215"
+ else:
+ color = "0xFFFFFF"
+
+ options = {"members": None}
+ actual = do_autodoc(app, 'module', 'target.preserve_defaults', options)
+ assert list(actual) == [
+ '',
+ '.. py:module:: target.preserve_defaults',
+ '',
+ '',
+ '.. py:class:: Class()',
+ ' :module: target.preserve_defaults',
+ '',
+ ' docstring',
+ '',
+ '',
+ ' .. py:method:: Class.clsmeth(name: str = CONSTANT, sentinel: ~typing.Any = '
+ 'SENTINEL, now: ~datetime.datetime = datetime.now(), color: int = %s, *, '
+ 'kwarg1, kwarg2=%s) -> None' % (color, color),
+ ' :module: target.preserve_defaults',
+ ' :classmethod:',
+ '',
+ ' docstring',
+ '',
+ '',
+ ' .. py:method:: Class.meth(name: str = CONSTANT, sentinel: ~typing.Any = '
+ 'SENTINEL, now: ~datetime.datetime = datetime.now(), color: int = %s, *, '
+ 'kwarg1, kwarg2=%s) -> None' % (color, color),
+ ' :module: target.preserve_defaults',
+ '',
+ ' docstring',
+ '',
+ '',
+ '.. py:function:: foo(name: str = CONSTANT, sentinel: ~typing.Any = SENTINEL, '
+ 'now: ~datetime.datetime = datetime.now(), color: int = %s, *, kwarg1, '
+ 'kwarg2=%s) -> None' % (color, color),
+ ' :module: target.preserve_defaults',
+ '',
+ ' docstring',
+ '',
+ ]