summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2022-04-02 16:55:48 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2022-04-02 16:55:48 +0900
commitf5e4e7081771a5fd5a0488d94e5fb425a0e41243 (patch)
treed1fd21ef34c44c7610971a8b643cfc414abb8abd /tests
parent9141464b8bcd4f2ade902107872fd001655a5131 (diff)
downloadsphinx-git-f5e4e7081771a5fd5a0488d94e5fb425a0e41243.tar.gz
Fix #10266: autodoc_preserve_defaults crashes on kwonlyargs w/o defaults
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-ext-autodoc/target/preserve_defaults.py8
-rw-r--r--tests/test_ext_autodoc_preserve_defaults.py6
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/roots/test-ext-autodoc/target/preserve_defaults.py b/tests/roots/test-ext-autodoc/target/preserve_defaults.py
index 422d41b95..fc83cf4fc 100644
--- a/tests/roots/test-ext-autodoc/target/preserve_defaults.py
+++ b/tests/roots/test-ext-autodoc/target/preserve_defaults.py
@@ -8,7 +8,10 @@ SENTINEL = object()
def foo(name: str = CONSTANT,
sentinel: Any = SENTINEL,
now: datetime = datetime.now(),
- color: int = 0xFFFFFF) -> None:
+ color: int = 0xFFFFFF,
+ *,
+ kwarg1,
+ kwarg2 = 0xFFFFFF) -> None:
"""docstring"""
@@ -16,5 +19,6 @@ class Class:
"""docstring"""
def meth(self, name: str = CONSTANT, sentinel: Any = SENTINEL,
- now: datetime = datetime.now(), color: int = 0xFFFFFF) -> None:
+ now: datetime = datetime.now(), color: int = 0xFFFFFF,
+ *, kwarg1, kwarg2 = 0xFFFFFF) -> None:
"""docstring"""
diff --git a/tests/test_ext_autodoc_preserve_defaults.py b/tests/test_ext_autodoc_preserve_defaults.py
index 16650b2c7..fe62c929e 100644
--- a/tests/test_ext_autodoc_preserve_defaults.py
+++ b/tests/test_ext_autodoc_preserve_defaults.py
@@ -29,14 +29,16 @@ def test_preserve_defaults(app):
'',
'',
' .. py:method:: Class.meth(name: str = CONSTANT, sentinel: ~typing.Any = '
- 'SENTINEL, now: ~datetime.datetime = datetime.now(), color: int = %s) -> None' % color,
+ '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) -> None' % color,
+ 'now: ~datetime.datetime = datetime.now(), color: int = %s, *, kwarg1, '
+ 'kwarg2=%s) -> None' % (color, color),
' :module: target.preserve_defaults',
'',
' docstring',