diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-12-23 11:56:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-23 09:56:30 +0000 |
commit | 4e5b27e6a3be85853bd04d45128dd7cc706bb1c8 (patch) | |
tree | 2b82e7eaaff8888196988d7e6f147ca4f159d426 /Lib/test/test_pydoc.py | |
parent | c3f92f6a7513340dfe2d82bfcd38eb77453e935d (diff) | |
download | cpython-4e5b27e6a3be85853bd04d45128dd7cc706bb1c8.tar.gz cpython-4e5b27e6a3be85853bd04d45128dd7cc706bb1c8.zip |
gh-81682: Fix test failures when CPython is built without docstrings (GH-113410)
Diffstat (limited to 'Lib/test/test_pydoc.py')
-rw-r--r-- | Lib/test/test_pydoc.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index eb50510e12b..982ee60c0be 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -32,7 +32,7 @@ from test.support.script_helper import (assert_python_ok, from test.support import threading_helper from test.support import (reap_children, captured_output, captured_stdout, captured_stderr, is_emscripten, is_wasi, - requires_docstrings) + requires_docstrings, MISSING_C_DOCSTRINGS) from test.support.os_helper import (TESTFN, rmtree, unlink) from test import pydoc_mod @@ -906,12 +906,13 @@ class A(builtins.object) | ---------------------------------------------------------------------- | Data descriptors defined here: | - | __dict__ - | dictionary for instance variables + | __dict__%s | - | __weakref__ - | list of weak references to the object -''' % __name__) + | __weakref__%s +''' % (__name__, + '' if MISSING_C_DOCSTRINGS else '\n | dictionary for instance variables', + '' if MISSING_C_DOCSTRINGS else '\n | list of weak references to the object', + )) def func( arg1: Callable[[Annotated[int, 'Some doc']], str], @@ -1154,13 +1155,15 @@ class TestDescriptions(unittest.TestCase): doc = pydoc.render_doc(typing.List[int], renderer=pydoc.plaintext) self.assertIn('_GenericAlias in module typing', doc) self.assertIn('List = class list(object)', doc) - self.assertIn(list.__doc__.strip().splitlines()[0], doc) + if not MISSING_C_DOCSTRINGS: + self.assertIn(list.__doc__.strip().splitlines()[0], doc) self.assertEqual(pydoc.describe(list[int]), 'GenericAlias') doc = pydoc.render_doc(list[int], renderer=pydoc.plaintext) self.assertIn('GenericAlias in module builtins', doc) self.assertIn('\nclass list(object)', doc) - self.assertIn(list.__doc__.strip().splitlines()[0], doc) + if not MISSING_C_DOCSTRINGS: + self.assertIn(list.__doc__.strip().splitlines()[0], doc) def test_union_type(self): self.assertEqual(pydoc.describe(typing.Union[int, str]), '_UnionGenericAlias') @@ -1174,7 +1177,8 @@ class TestDescriptions(unittest.TestCase): doc = pydoc.render_doc(int | str, renderer=pydoc.plaintext) self.assertIn('UnionType in module types object', doc) self.assertIn('\nclass UnionType(builtins.object)', doc) - self.assertIn(types.UnionType.__doc__.strip().splitlines()[0], doc) + if not MISSING_C_DOCSTRINGS: + self.assertIn(types.UnionType.__doc__.strip().splitlines()[0], doc) def test_special_form(self): self.assertEqual(pydoc.describe(typing.NoReturn), '_SpecialForm') @@ -1327,6 +1331,7 @@ class TestDescriptions(unittest.TestCase): "__class_getitem__(object, /) method of builtins.type instance") @support.cpython_only + @requires_docstrings def test_module_level_callable_unrepresentable_default(self): import _testcapi builtin = _testcapi.func_with_unrepresentable_signature @@ -1334,6 +1339,7 @@ class TestDescriptions(unittest.TestCase): "func_with_unrepresentable_signature(a, b=<x>)") @support.cpython_only + @requires_docstrings def test_builtin_staticmethod_unrepresentable_default(self): self.assertEqual(self._get_summary_line(str.maketrans), "maketrans(x, y=<unrepresentable>, z=<unrepresentable>, /)") @@ -1343,6 +1349,7 @@ class TestDescriptions(unittest.TestCase): "staticmeth(a, b=<x>)") @support.cpython_only + @requires_docstrings def test_unbound_builtin_method_unrepresentable_default(self): self.assertEqual(self._get_summary_line(dict.pop), "pop(self, key, default=<unrepresentable>, /)") @@ -1352,6 +1359,7 @@ class TestDescriptions(unittest.TestCase): "meth(self, /, a, b=<x>)") @support.cpython_only + @requires_docstrings def test_bound_builtin_method_unrepresentable_default(self): self.assertEqual(self._get_summary_line({}.pop), "pop(key, default=<unrepresentable>, /) " @@ -1363,6 +1371,7 @@ class TestDescriptions(unittest.TestCase): "method of _testcapi.DocStringUnrepresentableSignatureTest instance") @support.cpython_only + @requires_docstrings def test_unbound_builtin_classmethod_unrepresentable_default(self): import _testcapi cls = _testcapi.DocStringUnrepresentableSignatureTest @@ -1371,6 +1380,7 @@ class TestDescriptions(unittest.TestCase): "classmeth(type, /, a, b=<x>)") @support.cpython_only + @requires_docstrings def test_bound_builtin_classmethod_unrepresentable_default(self): import _testcapi cls = _testcapi.DocStringUnrepresentableSignatureTest |