mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
gh-128923: fix test_pydoc for object subclasses without __module__
(#128951)
Fix pydoc's docclass() for classes inheriting from object without the `__module__` attribute, like `_testcapi.HeapType`.
This commit is contained in:
parent
13c4def692
commit
d4544cb232
2 changed files with 10 additions and 1 deletions
|
@ -556,6 +556,14 @@ class PydocDocTest(unittest.TestCase):
|
|||
| ... and 82 other subclasses
|
||||
"""
|
||||
doc = pydoc.TextDoc()
|
||||
try:
|
||||
# Make sure HeapType, which has no __module__ attribute, is one
|
||||
# of the known subclasses of object. (doc.docclass() used to
|
||||
# fail if HeapType was imported before running this test, like
|
||||
# when running tests sequentially.)
|
||||
from _testcapi import HeapType
|
||||
except ImportError:
|
||||
pass
|
||||
text = doc.docclass(object)
|
||||
snip = (" | Built-in subclasses:\n"
|
||||
" | async_generator\n"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue