@@ -1321,6 +1321,21 @@ def test_programmatic_function_type_from_subclass_with_start(self):
1321
1321
self .assertIn (e , MinorEnum )
1322
1322
self .assertIs (type (e ), MinorEnum )
1323
1323
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
+
1324
1339
def test_intenum_from_bytes (self ):
1325
1340
self .assertIs (IntStooges .from_bytes (b'\x00 \x03 ' , 'big' ), IntStooges .MOE )
1326
1341
with self .assertRaises (ValueError ):
@@ -1463,7 +1478,7 @@ class MoreColor(Color):
1463
1478
class EvenMoreColor (Color , IntEnum ):
1464
1479
chartruese = 7
1465
1480
#
1466
- with self .assertRaisesRegex (TypeError , "<enum .Foo.> cannot extend <enum . Color.> " ):
1481
+ with self .assertRaisesRegex (ValueError , "\( .Foo., \(.pink., .black.\)\) is not a valid .* Color" ):
1467
1482
Color ('Foo' , ('pink' , 'black' ))
1468
1483
1469
1484
def test_exclude_methods (self ):
@@ -4181,7 +4196,7 @@ class TestEnumTypeSubclassing(unittest.TestCase):
4181
4196
Help on class Color in module %s:
4182
4197
4183
4198
class 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)
4185
4200
|
4186
4201
| Method resolution order:
4187
4202
| Color
@@ -4237,7 +4252,7 @@ class Color(enum.Enum)
4237
4252
Help on class Color in module %s:
4238
4253
4239
4254
class 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)
4241
4256
|
4242
4257
| Method resolution order:
4243
4258
| Color
0 commit comments