]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Enum] improve test, add andrei kulakov to ACKS (GH-26726)
authorEthan Furman <ethan@stoneleaf.us>
Tue, 15 Jun 2021 18:38:15 +0000 (11:38 -0700)
committerGitHub <noreply@github.com>
Tue, 15 Jun 2021 18:38:15 +0000 (11:38 -0700)
Lib/test/test_enum.py
Misc/ACKS

index 956b8347b1e1cb9e40f74ece6e4819cee5e01d43..4626c2435c1ab633068ab524159e1f7a647b49b2 100644 (file)
@@ -660,12 +660,35 @@ class TestEnum(unittest.TestCase):
         self.assertEqual(repr(MyEnum.A), '<MyEnum.A: 0x1>')
         #
         class SillyInt(HexInt):
+            __qualname__ = 'SillyInt'
             pass
         class MyOtherEnum(SillyInt, enum.Enum):
+            __qualname__ = 'MyOtherEnum'
             D = 4
             E = 5
             F = 6
         self.assertIs(MyOtherEnum._member_type_, SillyInt)
+        globals()['SillyInt'] = SillyInt
+        globals()['MyOtherEnum'] = MyOtherEnum
+        test_pickle_dump_load(self.assertIs, MyOtherEnum.E)
+        test_pickle_dump_load(self.assertIs, MyOtherEnum)
+        #
+        # This did not work in 3.9, but does now with pickling by name
+        class UnBrokenInt(int):
+            __qualname__ = 'UnBrokenInt'
+            def __new__(cls, value):
+                return int.__new__(cls, value)
+        class MyUnBrokenEnum(UnBrokenInt, Enum):
+            __qualname__ = 'MyUnBrokenEnum'
+            G = 7
+            H = 8
+            I = 9
+        self.assertIs(MyUnBrokenEnum._member_type_, UnBrokenInt)
+        self.assertIs(MyUnBrokenEnum(7), MyUnBrokenEnum.G)
+        globals()['UnBrokenInt'] = UnBrokenInt
+        globals()['MyUnBrokenEnum'] = MyUnBrokenEnum
+        test_pickle_dump_load(self.assertIs, MyUnBrokenEnum.I)
+        test_pickle_dump_load(self.assertIs, MyUnBrokenEnum)
 
     def test_too_many_data_types(self):
         with self.assertRaisesRegex(TypeError, 'too many data types'):
index e8c99257ec611e08095345b4f73c6924aad700d1..87de95b938c20e9e791ed37627a74f34811585e8 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -970,6 +970,7 @@ Andrew Kuchling
 Jakub Kuczys
 Dave Kuhlman
 Jon Kuhn
+Andrei Kulakov
 Ilya Kulakov
 Upendra Kumar
 Toshio Kuratomi