@@ -1321,6 +1321,21 @@ def test_programmatic_function_type_from_subclass_with_start(self):
13211321 self .assertIn (e , MinorEnum )
13221322 self .assertIs (type (e ), MinorEnum )
13231323
1324+ def test_programmatic_function_is_value_call (self ):
1325+ class TwoPart (Enum ):
1326+ ONE = 1 , 1.0
1327+ TWO = 2 , 2.0
1328+ THREE = 3 , 3.0
1329+ self .assertRaisesRegex (ValueError , '1 is not a valid .*TwoPart' , TwoPart , 1 )
1330+ self .assertIs (TwoPart ((1 , 1.0 )), TwoPart .ONE )
1331+ self .assertIs (TwoPart (1 , 1.0 ), TwoPart .ONE )
1332+ class ThreePart (Enum ):
1333+ ONE = 1 , 1.0 , 'one'
1334+ TWO = 2 , 2.0 , 'two'
1335+ THREE = 3 , 3.0 , 'three'
1336+ self .assertIs (ThreePart ((3 , 3.0 , 'three' )), ThreePart .THREE )
1337+ self .assertIs (ThreePart (3 , 3.0 , 'three' ), ThreePart .THREE )
1338+
13241339 def test_intenum_from_bytes (self ):
13251340 self .assertIs (IntStooges .from_bytes (b'\x00 \x03 ' , 'big' ), IntStooges .MOE )
13261341 with self .assertRaises (ValueError ):
@@ -1463,7 +1478,7 @@ class MoreColor(Color):
14631478 class EvenMoreColor (Color , IntEnum ):
14641479 chartruese = 7
14651480 #
1466- with self .assertRaisesRegex (TypeError , "<enum .Foo.> cannot extend <enum . Color.> " ):
1481+ with self .assertRaisesRegex (ValueError , "\( .Foo., \(.pink., .black.\)\) is not a valid .* Color" ):
14671482 Color ('Foo' , ('pink' , 'black' ))
14681483
14691484 def test_exclude_methods (self ):
@@ -4181,7 +4196,7 @@ class TestEnumTypeSubclassing(unittest.TestCase):
41814196 Help on class Color in module %s:
41824197
41834198class Color(enum.Enum)
4184- | Color(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
4199+ | Color(value, names=None, *values , module=None, qualname=None, type=None, start=1, boundary=None)
41854200 |
41864201 | Method resolution order:
41874202 | Color
@@ -4237,7 +4252,7 @@ class Color(enum.Enum)
42374252 Help on class Color in module %s:
42384253
42394254class Color(enum.Enum)
4240- | Color(value, names=None, *, module=None, qualname=None, type=None, start=1)
4255+ | Color(value, names=None, *values , module=None, qualname=None, type=None, start=1)
42414256 |
42424257 | Method resolution order:
42434258 | Color
0 commit comments