summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2021-06-15 18:38:15 (GMT)
committerGitHub <noreply@github.com>2021-06-15 18:38:15 (GMT)
commitcb2014f2077c92c35486bf0db7e646a68478a7a5 (patch)
treeff613cb369fa0695df3c30923f4547cbb719bcb3
parent243fd01047ddce1a7eb0f99a49732d123e942c63 (diff)
downloadcpython-cb2014f2077c92c35486bf0db7e646a68478a7a5.zip
cpython-cb2014f2077c92c35486bf0db7e646a68478a7a5.tar.gz
cpython-cb2014f2077c92c35486bf0db7e646a68478a7a5.tar.bz2
[Enum] improve test, add andrei kulakov to ACKS (GH-26726)
-rw-r--r--Lib/test/test_enum.py23
-rw-r--r--Misc/ACKS1
2 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index 956b834..4626c24 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -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'):
diff --git a/Misc/ACKS b/Misc/ACKS
index e8c9925..87de95b 100644
--- 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