@@ -4440,6 +4440,15 @@ def test__all__(self):
4440
4440
CONVERT_STRING_TEST_NAME_E = 5
4441
4441
CONVERT_STRING_TEST_NAME_F = 5
4442
4442
4443
+ # We also need values that cannot be compared:
4444
+ UNCOMPARABLE_A = 5
4445
+ UNCOMPARABLE_C = (9 , 1 ) # naming order is broken on purpose
4446
+ UNCOMPARABLE_B = 'value'
4447
+
4448
+ COMPLEX_C = 1j
4449
+ COMPLEX_A = 2j
4450
+ COMPLEX_B = 3j
4451
+
4443
4452
class TestIntEnumConvert (unittest .TestCase ):
4444
4453
def setUp (self ):
4445
4454
# Reset the module-level test variables to their original integer
@@ -4477,6 +4486,32 @@ def test_convert(self):
4477
4486
and name not in dir (IntEnum )],
4478
4487
[], msg = 'Names other than CONVERT_TEST_* found.' )
4479
4488
4489
+ def test_convert_uncomparable (self ):
4490
+ uncomp = enum .Enum ._convert_ (
4491
+ 'Uncomparable' ,
4492
+ MODULE ,
4493
+ filter = lambda x : x .startswith ('UNCOMPARABLE_' ),
4494
+ )
4495
+
4496
+ # Should be ordered by `name` only:
4497
+ self .assertEqual (
4498
+ list (uncomp ),
4499
+ [uncomp .UNCOMPARABLE_A , uncomp .UNCOMPARABLE_B , uncomp .UNCOMPARABLE_C ],
4500
+ )
4501
+
4502
+ def test_convert_complex (self ):
4503
+ uncomp = enum .Enum ._convert_ (
4504
+ 'Uncomparable' ,
4505
+ MODULE ,
4506
+ filter = lambda x : x .startswith ('COMPLEX_' ),
4507
+ )
4508
+
4509
+ # Should be ordered by `name` only:
4510
+ self .assertEqual (
4511
+ list (uncomp ),
4512
+ [uncomp .COMPLEX_A , uncomp .COMPLEX_B , uncomp .COMPLEX_C ],
4513
+ )
4514
+
4480
4515
@unittest .skipUnless (python_version == (3 , 8 ),
4481
4516
'_convert was deprecated in 3.8' )
4482
4517
def test_convert_warn (self ):
0 commit comments