@@ -660,12 +660,35 @@ def __repr__(self):
660
660
self .assertEqual (repr (MyEnum .A ), '<MyEnum.A: 0x1>' )
661
661
#
662
662
class SillyInt (HexInt ):
663
+ __qualname__ = 'SillyInt'
663
664
pass
664
665
class MyOtherEnum (SillyInt , enum .Enum ):
666
+ __qualname__ = 'MyOtherEnum'
665
667
D = 4
666
668
E = 5
667
669
F = 6
668
670
self .assertIs (MyOtherEnum ._member_type_ , SillyInt )
671
+ globals ()['SillyInt' ] = SillyInt
672
+ globals ()['MyOtherEnum' ] = MyOtherEnum
673
+ test_pickle_dump_load (self .assertIs , MyOtherEnum .E )
674
+ test_pickle_dump_load (self .assertIs , MyOtherEnum )
675
+ #
676
+ # This did not work in 3.9, but does now with pickling by name
677
+ class UnBrokenInt (int ):
678
+ __qualname__ = 'UnBrokenInt'
679
+ def __new__ (cls , value ):
680
+ return int .__new__ (cls , value )
681
+ class MyUnBrokenEnum (UnBrokenInt , Enum ):
682
+ __qualname__ = 'MyUnBrokenEnum'
683
+ G = 7
684
+ H = 8
685
+ I = 9
686
+ self .assertIs (MyUnBrokenEnum ._member_type_ , UnBrokenInt )
687
+ self .assertIs (MyUnBrokenEnum (7 ), MyUnBrokenEnum .G )
688
+ globals ()['UnBrokenInt' ] = UnBrokenInt
689
+ globals ()['MyUnBrokenEnum' ] = MyUnBrokenEnum
690
+ test_pickle_dump_load (self .assertIs , MyUnBrokenEnum .I )
691
+ test_pickle_dump_load (self .assertIs , MyUnBrokenEnum )
669
692
670
693
def test_too_many_data_types (self ):
671
694
with self .assertRaisesRegex (TypeError , 'too many data types' ):
@@ -3591,7 +3614,7 @@ class Bizarre(Flag):
3591
3614
self .assertEqual (Bizarre .d .value , 6 )
3592
3615
with self .assertRaisesRegex (
3593
3616
ValueError ,
3594
- "invalid Flag 'Bizarre': aliases b and d are missing combined values of 0x3 .use ` enum.show_flag_values.value.` for details." ,
3617
+ "invalid Flag 'Bizarre': aliases b and d are missing combined values of 0x3 .use enum.show_flag_values.value. for details." ,
3595
3618
):
3596
3619
@verify (NAMED_FLAGS )
3597
3620
class Bizarre (Flag ):
@@ -3610,7 +3633,7 @@ class Bizarre(IntFlag):
3610
3633
self .assertEqual (Bizarre .d .value , 6 )
3611
3634
with self .assertRaisesRegex (
3612
3635
ValueError ,
3613
- "invalid Flag 'Bizarre': alias d is missing value 0x2 .use ` enum.show_flag_values.value.` for details." ,
3636
+ "invalid Flag 'Bizarre': alias d is missing value 0x2 .use enum.show_flag_values.value. for details." ,
3614
3637
):
3615
3638
@verify (NAMED_FLAGS )
3616
3639
class Bizarre (IntFlag ):
0 commit comments