Skip to content

Commit

Permalink
pythongh-101100: Make __subclasses__ doctest stable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JelleZijlstra committed Sep 26, 2024
1 parent 46f5cbc commit 1313bf1
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 @@ -1109,8 +1109,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 '__main__.B'>]

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

0 comments on commit 1313bf1

Please sign in to comment.