21
21
(1 , 0 + 0j ),
22
22
)
23
23
24
- class MockIndex :
24
+ class WithIndex :
25
25
def __init__ (self , value ):
26
26
self .value = value
27
27
def __index__ (self ):
28
28
return self .value
29
29
30
- class MockFloat :
30
+ class WithFloat :
31
31
def __init__ (self , value ):
32
32
self .value = value
33
33
def __float__ (self ):
@@ -36,7 +36,7 @@ def __float__(self):
36
36
class ComplexSubclass (complex ):
37
37
pass
38
38
39
- class MockComplex :
39
+ class WithComplex :
40
40
def __init__ (self , value ):
41
41
self .value = value
42
42
def __complex__ (self ):
@@ -372,7 +372,7 @@ def check(z, x, y):
372
372
check (complex (4.25 + 0j ), 4.25 , 0.0 )
373
373
check (complex (4.25 + 0.5j ), 4.25 , 0.5 )
374
374
check (complex (ComplexSubclass (4.25 + 0.5j )), 4.25 , 0.5 )
375
- check (complex (MockComplex (4.25 + 0.5j )), 4.25 , 0.5 )
375
+ check (complex (WithComplex (4.25 + 0.5j )), 4.25 , 0.5 )
376
376
377
377
check (complex (1 , 10 ), 1.0 , 10.0 )
378
378
check (complex (1 , 10.0 ), 1.0 , 10.0 )
@@ -389,8 +389,8 @@ def check(z, x, y):
389
389
"argument 'real' must be a real number, not .*ComplexSubclass" ):
390
390
check (complex (ComplexSubclass (4.25 + 0j ), 0 ), 4.25 , 0.0 )
391
391
with self .assertWarnsRegex (DeprecationWarning ,
392
- "argument 'real' must be a real number, not .*MockComplex " ):
393
- check (complex (MockComplex (4.25 + 0j ), 0 ), 4.25 , 0.0 )
392
+ "argument 'real' must be a real number, not .*WithComplex " ):
393
+ check (complex (WithComplex (4.25 + 0j ), 0 ), 4.25 , 0.0 )
394
394
with self .assertWarnsRegex (DeprecationWarning ,
395
395
"argument 'real' must be a real number, not complex" ):
396
396
check (complex (4.25j , 0 ), 0.0 , 4.25 )
@@ -404,8 +404,8 @@ def check(z, x, y):
404
404
"argument 'imag' must be a real number, not .*ComplexSubclass" ):
405
405
check (complex (0 , ComplexSubclass (4.25 + 0j )), 0.0 , 4.25 )
406
406
with self .assertRaisesRegex (TypeError ,
407
- "argument 'imag' must be a real number, not .*MockComplex " ):
408
- complex (0 , MockComplex (4.25 + 0j ))
407
+ "argument 'imag' must be a real number, not .*WithComplex " ):
408
+ complex (0 , WithComplex (4.25 + 0j ))
409
409
with self .assertWarnsRegex (DeprecationWarning ,
410
410
"argument 'imag' must be a real number, not complex" ):
411
411
check (complex (0.0 , 4.25j ), - 4.25 , 0.0 )
@@ -467,13 +467,13 @@ def check(z, x, y):
467
467
"argument 'imag' must be a real number, not str" ,
468
468
complex , 0 , '1' )
469
469
470
- self .assertRaises (TypeError , complex , MockComplex (1.5 ))
471
- self .assertRaises (TypeError , complex , MockComplex (1 ))
472
- self .assertRaises (TypeError , complex , MockComplex (None ))
473
- self .assertRaises (TypeError , complex , MockComplex (4.25 + 0j ), object ())
474
- self .assertRaises (TypeError , complex , MockComplex (1.5 ), object ())
475
- self .assertRaises (TypeError , complex , MockComplex (1 ), object ())
476
- self .assertRaises (TypeError , complex , MockComplex (None ), object ())
470
+ self .assertRaises (TypeError , complex , WithComplex (1.5 ))
471
+ self .assertRaises (TypeError , complex , WithComplex (1 ))
472
+ self .assertRaises (TypeError , complex , WithComplex (None ))
473
+ self .assertRaises (TypeError , complex , WithComplex (4.25 + 0j ), object ())
474
+ self .assertRaises (TypeError , complex , WithComplex (1.5 ), object ())
475
+ self .assertRaises (TypeError , complex , WithComplex (1 ), object ())
476
+ self .assertRaises (TypeError , complex , WithComplex (None ), object ())
477
477
478
478
class EvilExc (Exception ):
479
479
pass
@@ -484,25 +484,25 @@ def __complex__(self):
484
484
485
485
self .assertRaises (EvilExc , complex , evilcomplex ())
486
486
487
- check (complex (MockFloat (4.25 )), 4.25 , 0.0 )
488
- check (complex (MockFloat (4.25 ), 1.5 ), 4.25 , 1.5 )
489
- check (complex (1.5 , MockFloat (4.25 )), 1.5 , 4.25 )
490
- self .assertRaises (TypeError , complex , MockFloat (42 ))
491
- self .assertRaises (TypeError , complex , MockFloat (42 ), 1.5 )
492
- self .assertRaises (TypeError , complex , 1.5 , MockFloat (42 ))
493
- self .assertRaises (TypeError , complex , MockFloat (None ))
494
- self .assertRaises (TypeError , complex , MockFloat (None ), 1.5 )
495
- self .assertRaises (TypeError , complex , 1.5 , MockFloat (None ))
496
-
497
- check (complex (MockIndex (42 )), 42.0 , 0.0 )
498
- check (complex (MockIndex (42 ), 1.5 ), 42.0 , 1.5 )
499
- check (complex (1.5 , MockIndex (42 )), 1.5 , 42.0 )
500
- self .assertRaises (OverflowError , complex , MockIndex (2 ** 2000 ))
501
- self .assertRaises (OverflowError , complex , MockIndex (2 ** 2000 ), 1.5 )
502
- self .assertRaises (OverflowError , complex , 1.5 , MockIndex (2 ** 2000 ))
503
- self .assertRaises (TypeError , complex , MockIndex (None ))
504
- self .assertRaises (TypeError , complex , MockIndex (None ), 1.5 )
505
- self .assertRaises (TypeError , complex , 1.5 , MockIndex (None ))
487
+ check (complex (WithFloat (4.25 )), 4.25 , 0.0 )
488
+ check (complex (WithFloat (4.25 ), 1.5 ), 4.25 , 1.5 )
489
+ check (complex (1.5 , WithFloat (4.25 )), 1.5 , 4.25 )
490
+ self .assertRaises (TypeError , complex , WithFloat (42 ))
491
+ self .assertRaises (TypeError , complex , WithFloat (42 ), 1.5 )
492
+ self .assertRaises (TypeError , complex , 1.5 , WithFloat (42 ))
493
+ self .assertRaises (TypeError , complex , WithFloat (None ))
494
+ self .assertRaises (TypeError , complex , WithFloat (None ), 1.5 )
495
+ self .assertRaises (TypeError , complex , 1.5 , WithFloat (None ))
496
+
497
+ check (complex (WithIndex (42 )), 42.0 , 0.0 )
498
+ check (complex (WithIndex (42 ), 1.5 ), 42.0 , 1.5 )
499
+ check (complex (1.5 , WithIndex (42 )), 1.5 , 42.0 )
500
+ self .assertRaises (OverflowError , complex , WithIndex (2 ** 2000 ))
501
+ self .assertRaises (OverflowError , complex , WithIndex (2 ** 2000 ), 1.5 )
502
+ self .assertRaises (OverflowError , complex , 1.5 , WithIndex (2 ** 2000 ))
503
+ self .assertRaises (TypeError , complex , WithIndex (None ))
504
+ self .assertRaises (TypeError , complex , WithIndex (None ), 1.5 )
505
+ self .assertRaises (TypeError , complex , 1.5 , WithIndex (None ))
506
506
507
507
class MyInt :
508
508
def __int__ (self ):
0 commit comments