2022-02-19 21:05:56 -06:00
|
|
|
"""Test the autodoc extension."""
|
2021-01-27 10:57:46 -06:00
|
|
|
|
2021-10-30 10:26:03 -05:00
|
|
|
import sys
|
|
|
|
|
2021-01-27 10:57:46 -06:00
|
|
|
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):
|
2021-10-30 10:26:03 -05:00
|
|
|
if sys.version_info < (3, 8):
|
|
|
|
color = "16777215"
|
|
|
|
else:
|
|
|
|
color = "0xFFFFFF"
|
|
|
|
|
2021-01-27 10:57:46 -06:00
|
|
|
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',
|
|
|
|
'',
|
|
|
|
'',
|
2022-01-01 04:37:42 -06:00
|
|
|
' .. py:method:: Class.meth(name: str = CONSTANT, sentinel: ~typing.Any = '
|
|
|
|
'SENTINEL, now: ~datetime.datetime = datetime.now(), color: int = %s) -> None' % color,
|
2021-01-27 10:57:46 -06:00
|
|
|
' :module: target.preserve_defaults',
|
|
|
|
'',
|
|
|
|
' docstring',
|
|
|
|
'',
|
|
|
|
'',
|
2022-01-01 04:37:42 -06:00
|
|
|
'.. py:function:: foo(name: str = CONSTANT, sentinel: ~typing.Any = SENTINEL, '
|
|
|
|
'now: ~datetime.datetime = datetime.now(), color: int = %s) -> None' % color,
|
2021-01-27 10:57:46 -06:00
|
|
|
' :module: target.preserve_defaults',
|
|
|
|
'',
|
|
|
|
' docstring',
|
|
|
|
'',
|
|
|
|
]
|