]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43162: [Enum] update docs, renable doc tests (GH-24487)
authorEthan Furman <ethan@stoneleaf.us>
Wed, 3 Mar 2021 17:54:30 +0000 (09:54 -0800)
committerGitHub <noreply@github.com>
Wed, 3 Mar 2021 17:54:30 +0000 (09:54 -0800)
* update docs, renable doc tests
* make deprecation warning active for two releases

Doc/library/enum.rst
Lib/enum.py
Lib/test/test_enum.py

index b7f269464e794530cb827108c88227da014a7f0d..73b77cbc671cd526ebde2efeb3290722fe298c5f 100644 (file)
@@ -1222,17 +1222,18 @@ Private names are not converted to Enum members, but remain normal attributes.
 :class:`Enum` members are instances of their :class:`Enum` class, and are
 normally accessed as ``EnumClass.member``.  In Python versions ``3.5`` to
 ``3.9`` you could access members from other members -- this practice was
-discouraged, and in ``3.10`` :class:`Enum` has returned to not allowing it::
+discouraged, and in ``3.12`` :class:`Enum` will return to not allowing it,
+while in ``3.10`` and ``3.11`` it will raise a :exc:`DeprecationWarning`::
 
     >>> class FieldTypes(Enum):
     ...     name = 0
     ...     value = 1
     ...     size = 2
     ...
-    >>> FieldTypes.value.size
-    Traceback (most recent call last):
-    ...
-    AttributeError: FieldTypes: no attribute 'size'
+    >>> FieldTypes.value.size       # doctest: +SKIP
+    DeprecationWarning: accessing one member from another is not supported,
+      and will be disabled in 3.12
+    <FieldTypes.size: 2>
 
 .. versionchanged:: 3.5
 .. versionchanged:: 3.10
index 55299c5788244639125ee80a6fbb38694ec871e1..84c7b0dc2afbef7ce40632ab4fa42e8040bc41e6 100644 (file)
@@ -148,7 +148,7 @@ class property(DynamicClassAttribute):
                     import warnings
                     warnings.warn(
                             "accessing one member from another is not supported, "
-                            " and will be disabled in 3.11",
+                            " and will be disabled in 3.12",
                             DeprecationWarning,
                             stacklevel=2,
                             )
index 3982d1d6430430e8b437897cd4c17f8aeebff6e7..69392e01faacd5d802835df74763a8eedf77fce8 100644 (file)
@@ -18,7 +18,7 @@ from datetime import timedelta
 
 def load_tests(loader, tests, ignore):
     tests.addTests(doctest.DocTestSuite(enum))
-    if os.path.exists('../../Doc/library/enum.rst'):
+    if os.path.exists('Doc/library/enum.rst'):
         tests.addTests(doctest.DocFileSuite(
                 '../../Doc/library/enum.rst',
                 optionflags=doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE,
@@ -2186,7 +2186,7 @@ class TestEnum(unittest.TestCase):
         self.assertEqual(Private._Private__major_, 'Hoolihan')
 
     @unittest.skipUnless(
-            sys.version_info[:2] == (3, 10),
+            sys.version_info[:2] < (3, 12),
             'member-member access now raises an exception',
             )
     def test_warning_for_member_from_member_access(self):
@@ -2198,7 +2198,7 @@ class TestEnum(unittest.TestCase):
         self.assertIs(Di.NO, nope)
 
     @unittest.skipUnless(
-            sys.version_info[:2] > (3, 10),
+            sys.version_info[:2] >= (3, 12),
             'member-member access currently issues a warning',
             )
     def test_exception_for_member_from_member_access(self):