]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-101100: Make __subclasses__ doctest stable (#124577)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Thu, 26 Sep 2024 06:26:03 +0000 (23:26 -0700)
committerGitHub <noreply@github.com>
Thu, 26 Sep 2024 06:26:03 +0000 (06:26 +0000)
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.

Doc/reference/datamodel.rst

index a6348eda3891cc4c3f07ac44b4e2d88de5f2505d..5ce6bf17db41eabb2bfbb14895f8da0356313124 100644 (file)
@@ -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 'B'>]
 
 Class instances
 ---------------