@@ -60,29 +60,29 @@ def test_int_subclassing():
60
60
MAXREPEAT = _NamedIntConstant (1 , 'MAXREPEAT' )
61
61
assert MAXREPEAT == 1
62
62
assert str (MAXREPEAT ) == "MAXREPEAT"
63
-
63
+
64
64
65
65
def test_boolean2int ():
66
66
assert int (True ) == 1
67
67
assert int (False ) == 0
68
-
69
-
68
+
69
+
70
70
def test_int_from_custom ():
71
71
class CustomInt4 ():
72
72
def __int__ (self ):
73
73
return 1
74
-
74
+
75
75
class CustomInt8 ():
76
76
def __int__ (self ):
77
77
return 0xCAFEBABECAFED00D
78
-
78
+
79
79
class SubInt (int ):
80
80
def __int__ (self ):
81
81
return 0xBADF00D
82
-
82
+
83
83
class NoInt ():
84
84
pass
85
-
85
+
86
86
assert int (CustomInt4 ()) == 1
87
87
assert int (CustomInt8 ()) == 0xCAFEBABECAFED00D
88
88
assert CustomInt8 () != 0xCAFEBABECAFED00D
@@ -124,7 +124,7 @@ def builtinTest(number):
124
124
builtinTest (9 )
125
125
builtinTest (6227020800 )
126
126
builtinTest (9999992432902008176640000999999 )
127
-
127
+
128
128
assert True .__int__ () == 1
129
129
assert False .__int__ () == 0
130
130
@@ -161,13 +161,13 @@ def builtinTest(number):
161
161
builtinTest (9 )
162
162
builtinTest (6227020800 )
163
163
builtinTest (9999992432902008176640000999999 )
164
-
164
+
165
165
assert True .real == 1
166
166
assert False .real == 0
167
167
assert True .imag == 0
168
168
assert False .imag == 0
169
169
170
- def test_real_imag_subclass ():
170
+ def test_real_imag_subclass ():
171
171
def subclassTest (number ):
172
172
a = MyInt (number )
173
173
b = a .real
@@ -202,7 +202,7 @@ def builtinTest(number):
202
202
builtinTest (9 )
203
203
builtinTest (6227020800 )
204
204
builtinTest (9999992432902008176640000999999 )
205
-
205
+
206
206
assert True .numerator == 1
207
207
assert False .numerator == 0
208
208
assert True .denominator == 1
@@ -240,7 +240,7 @@ def builtinTest(number):
240
240
builtinTest (9 )
241
241
builtinTest (6227020800 )
242
242
builtinTest (9999992432902008176640000999999 )
243
-
243
+
244
244
assert True .conjugate () == 1
245
245
assert False .conjugate () == 0
246
246
@@ -282,7 +282,7 @@ def builtinTest(number):
282
282
builtinTest (9 )
283
283
builtinTest (6227020800 )
284
284
builtinTest (9999992432902008176640000999999 )
285
-
285
+
286
286
assert True .__trunc__ () == 1
287
287
assert False .__trunc__ () == 0
288
288
@@ -325,7 +325,7 @@ def test_create_int_from_string():
325
325
326
326
327
327
class FromBytesTests (unittest .TestCase ):
328
-
328
+
329
329
def check (self , tests , byteorder , signed = False ):
330
330
for test , expected in tests .items ():
331
331
try :
@@ -447,10 +447,10 @@ def test_from_list(self):
447
447
class LyingList (list ):
448
448
def __iter__ (self ):
449
449
return iter ([10 , 20 , 30 , 40 ])
450
-
450
+
451
451
self .assertEqual (
452
452
int .from_bytes (LyingList ([255 , 1 , 1 ]), 'big' ), 169090600 )
453
-
453
+
454
454
def test_from_tuple (self ):
455
455
self .assertEqual (
456
456
int .from_bytes ((255 , 0 , 0 ), 'big' , signed = True ), - 65536 )
@@ -464,7 +464,7 @@ def __iter__(self):
464
464
return iter ((15 , 25 , 35 , 45 ))
465
465
self .assertEqual (
466
466
int .from_bytes (LyingTuple ((255 , 1 , 1 )), 'big' ), 253305645 )
467
-
467
+
468
468
def test_from_bytearray (self ):
469
469
self .assertEqual (int .from_bytes (
470
470
bytearray (b'\xff \x00 \x00 ' ), 'big' , signed = True ), - 65536 )
@@ -549,7 +549,7 @@ class mybyteslike2():
549
549
def __bytes__ (self ):
550
550
return array .array ('b' , [2 , 2 , 3 ])
551
551
552
- self .assertRaises (TypeError , int .from_bytes , mybyteslike2 (), 'big' )
552
+ self .assertRaises (TypeError , int .from_bytes , mybyteslike2 (), 'big' )
553
553
554
554
def test_from_list_with_byteslike (self ):
555
555
class StrangeList (list ):
@@ -563,7 +563,7 @@ def __iter__(self):
563
563
class ToBytesTests (unittest .TestCase ):
564
564
565
565
class MyInt (int ):
566
- pass
566
+ pass
567
567
568
568
def check (self , tests , byteorder , signed = False ):
569
569
for test , expected in tests .items ():
@@ -633,7 +633,7 @@ def test_SignedLittleEndian(self):
633
633
}
634
634
self .check (tests2 , 'little' , signed = True )
635
635
self .checkPIntSpec (tests2 , 'little' , signed = True )
636
-
636
+
637
637
def test_UnsignedBigEndian (self ):
638
638
# Convert integers to unsigned big-endian byte arrays.
639
639
tests3 = {
@@ -705,7 +705,5 @@ def __int__(self):
705
705
return 3
706
706
def __index__ (self ):
707
707
return 4
708
-
709
- self .assertEqual (MyTest (1 ).to_bytes (MyTest (10 ), 'big' ), b'\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x01 ' )
710
-
711
708
709
+ self .assertEqual (MyTest (1 ).to_bytes (MyTest (10 ), 'big' ), b'\x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x00 \x01 ' )
0 commit comments