Skip to content

Commit

Permalink
[3.12] pythongh-101100: Make __subclasses__ doctest stable (pythonGH-…
Browse files Browse the repository at this point in the history
…124577)

Using a standard library class makes this test difficult to maintain
as other tests and other parts of the stdlib may create subclasses,
which may still be alive when this test runs depending on GC timing.
(cherry picked from commit 08a467b)

Co-authored-by: Jelle Zijlstra <[email protected]>
  • Loading branch information
JelleZijlstra committed Sep 26, 2024
1 parent 2b54a4e commit afc77b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Doc/reference/datamodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,10 @@ have the following two methods available:

.. doctest::

>>> int.__subclasses__()
[<class 'bool'>, <enum 'IntEnum'>, <flag 'IntFlag'>, <class 're._constants._NamedIntConstant'>]
>>> class A: pass
>>> class B(A): pass
>>> A.__subclasses__()
[<class 'B'>]

Class instances
---------------
Expand Down

0 comments on commit afc77b2

Please sign in to comment.