Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more tests.
  • Loading branch information
serhiy-storchaka committed Apr 9, 2025
commit 452bb6f86526f2f3e705dd06c693a4765aaec1a7
27 changes: 26 additions & 1 deletion Lib/test/test_pydoc/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,10 @@ def _get_summary_line(o):
text = pydoc.plain(pydoc.render_doc(o))
lines = text.split('\n')
assert len(lines) >= 2
return lines[2]
for i in range(3, len(lines)):
if lines[i].startswith(' '):
break
return '\n'.join(lines[2:i])

@staticmethod
def _get_summary_lines(o):
Expand Down Expand Up @@ -1650,6 +1653,28 @@ def test_bound_builtin_method_unrepresentable_default(self):
"meth(a, b=<x>) "
"method of _testcapi.DocStringUnrepresentableSignatureTest instance")

@support.cpython_only
@requires_docstrings
def test_unbound_builtin_method_multisig_unrepresentable_default(self):
_testcapi = import_helper.import_module("_testcapi")
cls = _testcapi.DocStringUnrepresentableSignatureTest
self.assertEqual(self._get_summary_line(cls.meth_multi),
"meth_multi(self, /) unbound "
"_testcapi.DocStringUnrepresentableSignatureTest method\n"
"meth_multi(self, /, a, b=<x>) unbound "
"_testcapi.DocStringUnrepresentableSignatureTest method")

@support.cpython_only
@requires_docstrings
def test_bound_builtin_method_multisig_unrepresentable_default(self):
_testcapi = import_helper.import_module("_testcapi")
obj = _testcapi.DocStringUnrepresentableSignatureTest()
self.assertEqual(self._get_summary_line(obj.meth_multi),
"meth_multi() "
"method of _testcapi.DocStringUnrepresentableSignatureTest instance\n"
"meth_multi(a, b=<x>) "
"method of _testcapi.DocStringUnrepresentableSignatureTest instance")

@support.cpython_only
@requires_docstrings
def test_unbound_builtin_classmethod_unrepresentable_default(self):
Expand Down
3 changes: 2 additions & 1 deletion Modules/_testcapi/docstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ static PyMethodDef DocStringUnrepresentableSignatureTest_methods[] = {
{"meth_multi",
(PyCFunction)test_with_docstring, METH_VARARGS,
PyDoc_STR(
"meth_multi($self, /, a, b=<x>)\n"
"meth_multi($self, /)\n"
"($self, /, a, b=<x>)\n"
"--\n\n"
"This docstring has a multisignature with unrepresentable default."
)},
Expand Down