@@ -2737,10 +2737,10 @@ def __repr__(self):
2737
2737
return 'ha hah!'
2738
2738
class Entries (Foo , Enum ):
2739
2739
ENTRY1 = 1
2740
+ self .assertEqual (repr (Entries .ENTRY1 ), '<Entries.ENTRY1: ha hah!>' )
2741
+ self .assertTrue (Entries .ENTRY1 .value == Foo (1 ), Entries .ENTRY1 .value )
2740
2742
self .assertTrue (isinstance (Entries .ENTRY1 , Foo ))
2741
2743
self .assertTrue (Entries ._member_type_ is Foo , Entries ._member_type_ )
2742
- self .assertTrue (Entries .ENTRY1 .value == Foo (1 ), Entries .ENTRY1 .value )
2743
- self .assertEqual (repr (Entries .ENTRY1 ), '<Entries.ENTRY1: ha hah!>' )
2744
2744
#
2745
2745
# check auto-generated dataclass __repr__ is not used
2746
2746
#
@@ -2787,8 +2787,7 @@ class Creature(CreatureDataMixin, Enum):
2787
2787
DOG = ('medium' , 4 )
2788
2788
self .assertRegex (repr (Creature .DOG ), "<Creature.DOG: .*CreatureDataMixin object at .*>" )
2789
2789
2790
- def test_repr_with_init_data_type_mixin (self ):
2791
- # non-data_type is a mixin that doesn't define __new__
2790
+ def test_repr_with_init_mixin (self ):
2792
2791
class Foo :
2793
2792
def __init__ (self , a ):
2794
2793
self .a = a
@@ -2797,9 +2796,9 @@ def __repr__(self):
2797
2796
class Entries (Foo , Enum ):
2798
2797
ENTRY1 = 1
2799
2798
#
2800
- self .assertEqual (repr (Entries .ENTRY1 ), '<Entries.ENTRY1: Foo(a=1)> ' )
2799
+ self .assertEqual (repr (Entries .ENTRY1 ), 'Foo(a=1)' )
2801
2800
2802
- def test_repr_and_str_with_non_data_type_mixin (self ):
2801
+ def test_repr_and_str_with_no_init_mixin (self ):
2803
2802
# non-data_type is a mixin that doesn't define __new__
2804
2803
class Foo :
2805
2804
def __repr__ (self ):
@@ -2911,6 +2910,8 @@ def __new__(cls, c):
2911
2910
2912
2911
def test_init_exception (self ):
2913
2912
class Base :
2913
+ def __new__ (cls , * args ):
2914
+ return object .__new__ (cls )
2914
2915
def __init__ (self , x ):
2915
2916
raise ValueError ("I don't like" , x )
2916
2917
with self .assertRaises (TypeError ):
0 commit comments