Skip to content

bpo-44342: [Enum] improve test, add andrei kulakov to ACKS #26726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,12 +660,35 @@ def __repr__(self):
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'):
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ Andrew Kuchling
Jakub Kuczys
Dave Kuhlman
Jon Kuhn
Andrei Kulakov
Ilya Kulakov
Upendra Kumar
Toshio Kuratomi
Expand Down