Skip to content

Commit

Permalink
[3.13] gh-101100: Make __subclasses__ doctest stable (GH-124577) (#12…
Browse files Browse the repository at this point in the history
…4579)

gh-101100: Make __subclasses__ doctest stable (GH-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
miss-islington and JelleZijlstra authored Sep 26, 2024
1 parent 410e0ef commit a079922
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 @@ -1053,8 +1053,10 @@ have the following two methods available:

.. doctest::

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

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

0 comments on commit a079922

Please sign in to comment.