@@ -2737,10 +2737,10 @@ def __repr__(self):
27372737 return 'ha hah!'
27382738 class Entries (Foo , Enum ):
27392739 ENTRY1 = 1
2740+ self .assertEqual (repr (Entries .ENTRY1 ), '<Entries.ENTRY1: ha hah!>' )
2741+ self .assertTrue (Entries .ENTRY1 .value == Foo (1 ), Entries .ENTRY1 .value )
27402742 self .assertTrue (isinstance (Entries .ENTRY1 , Foo ))
27412743 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!>' )
27442744 #
27452745 # check auto-generated dataclass __repr__ is not used
27462746 #
@@ -2787,8 +2787,7 @@ class Creature(CreatureDataMixin, Enum):
27872787 DOG = ('medium' , 4 )
27882788 self .assertRegex (repr (Creature .DOG ), "<Creature.DOG: .*CreatureDataMixin object at .*>" )
27892789
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 ):
27922791 class Foo :
27932792 def __init__ (self , a ):
27942793 self .a = a
@@ -2797,9 +2796,9 @@ def __repr__(self):
27972796 class Entries (Foo , Enum ):
27982797 ENTRY1 = 1
27992798 #
2800- self .assertEqual (repr (Entries .ENTRY1 ), '<Entries.ENTRY1: Foo(a=1)> ' )
2799+ self .assertEqual (repr (Entries .ENTRY1 ), 'Foo(a=1)' )
28012800
2802- def test_repr_and_str_with_non_data_type_mixin (self ):
2801+ def test_repr_and_str_with_no_init_mixin (self ):
28032802 # non-data_type is a mixin that doesn't define __new__
28042803 class Foo :
28052804 def __repr__ (self ):
@@ -2911,6 +2910,8 @@ def __new__(cls, c):
29112910
29122911 def test_init_exception (self ):
29132912 class Base :
2913+ def __new__ (cls , * args ):
2914+ return object .__new__ (cls )
29142915 def __init__ (self , x ):
29152916 raise ValueError ("I don't like" , x )
29162917 with self .assertRaises (TypeError ):
0 commit comments