Skip to content

Commit 8eeba89

Browse files
committed
Revert the format changed made by IDE automatically
1 parent 0b3db3c commit 8eeba89

File tree

1 file changed

+37
-65
lines changed

1 file changed

+37
-65
lines changed

Lib/test/test_array.py

Lines changed: 37 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@
2626
class ArraySubclass(array.array):
2727
pass
2828

29-
3029
class ArraySubclassWithKwargs(array.array):
3130
def __init__(self, typecode, newarg=None):
3231
array.array.__init__(self)
3332

34-
3533
typecodes = 'uwbBhHiIlLfdqQ'
3634

37-
3835
class MiscTest(unittest.TestCase):
3936

4037
def test_array_is_sequence(self):
41-
self.assertIsInstance(array.array(
42-
"B"), collections.abc.MutableSequence)
38+
self.assertIsInstance(array.array("B"), collections.abc.MutableSequence)
4339
self.assertIsInstance(array.array("B"), collections.abc.Reversible)
4440

4541
def test_bad_constructor(self):
@@ -144,32 +140,32 @@ def test_numbers(self):
144140
(['h', 'i', 'l'], SIGNED_INT16_BE, '>hhh',
145141
[-0x8000, 0x7fff, 0]),
146142
(['I', 'L'], UNSIGNED_INT32_LE, '<IIII',
147-
[1 << 31, (1 << 31)-1, 0, (1 << 32)-1]),
143+
[1<<31, (1<<31)-1, 0, (1<<32)-1]),
148144
(['I', 'L'], UNSIGNED_INT32_BE, '>IIII',
149-
[1 << 31, (1 << 31)-1, 0, (1 << 32)-1]),
145+
[1<<31, (1<<31)-1, 0, (1<<32)-1]),
150146
(['i', 'l'], SIGNED_INT32_LE, '<iii',
151-
[-1 << 31, (1 << 31)-1, 0]),
147+
[-1<<31, (1<<31)-1, 0]),
152148
(['i', 'l'], SIGNED_INT32_BE, '>iii',
153-
[-1 << 31, (1 << 31)-1, 0]),
149+
[-1<<31, (1<<31)-1, 0]),
154150
(['L'], UNSIGNED_INT64_LE, '<QQQQ',
155-
[1 << 31, (1 << 31)-1, 0, (1 << 32)-1]),
151+
[1<<31, (1<<31)-1, 0, (1<<32)-1]),
156152
(['L'], UNSIGNED_INT64_BE, '>QQQQ',
157-
[1 << 31, (1 << 31)-1, 0, (1 << 32)-1]),
153+
[1<<31, (1<<31)-1, 0, (1<<32)-1]),
158154
(['l'], SIGNED_INT64_LE, '<qqq',
159-
[-1 << 31, (1 << 31)-1, 0]),
155+
[-1<<31, (1<<31)-1, 0]),
160156
(['l'], SIGNED_INT64_BE, '>qqq',
161-
[-1 << 31, (1 << 31)-1, 0]),
157+
[-1<<31, (1<<31)-1, 0]),
162158
# The following tests for INT64 will raise an OverflowError
163159
# when run on a 32-bit machine. The tests are simply skipped
164160
# in that case.
165161
(['L'], UNSIGNED_INT64_LE, '<QQQQ',
166-
[1 << 63, (1 << 63)-1, 0, (1 << 64)-1]),
162+
[1<<63, (1<<63)-1, 0, (1<<64)-1]),
167163
(['L'], UNSIGNED_INT64_BE, '>QQQQ',
168-
[1 << 63, (1 << 63)-1, 0, (1 << 64)-1]),
164+
[1<<63, (1<<63)-1, 0, (1<<64)-1]),
169165
(['l'], SIGNED_INT64_LE, '<qqq',
170-
[-1 << 63, (1 << 63)-1, 0]),
166+
[-1<<63, (1<<63)-1, 0]),
171167
(['l'], SIGNED_INT64_BE, '>qqq',
172-
[-1 << 63, (1 << 63)-1, 0]),
168+
[-1<<63, (1<<63)-1, 0]),
173169
(['f'], IEEE_754_FLOAT_LE, '<ffff',
174170
[16711938.0, float('inf'), float('-inf'), -0.0]),
175171
(['f'], IEEE_754_FLOAT_BE, '>ffff',
@@ -190,7 +186,7 @@ def test_numbers(self):
190186
b = array_reconstructor(
191187
array.array, typecode, mformat_code, arraystr)
192188
self.assertEqual(a, b,
193-
msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
189+
msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
194190

195191
def test_unicode(self):
196192
teststr = "Bonne Journ\xe9e \U0002030a\U00020347"
@@ -207,7 +203,7 @@ def test_unicode(self):
207203
b = array_reconstructor(
208204
array.array, c, mformat_code, teststr.encode(encoding))
209205
self.assertEqual(a, b,
210-
msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
206+
msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
211207

212208

213209
class BaseTest:
@@ -268,7 +264,7 @@ def test_byteswap(self):
268264
if a.itemsize in (1, 2, 4, 8):
269265
b = array.array(self.typecode, example)
270266
b.byteswap()
271-
if a.itemsize == 1:
267+
if a.itemsize==1:
272268
self.assertEqual(a, b)
273269
else:
274270
self.assertNotEqual(a, b)
@@ -541,7 +537,7 @@ def test_tofrombytes(self):
541537
c = array.array(self.typecode, bytearray(a.tobytes()))
542538
self.assertEqual(a, b)
543539
self.assertEqual(a, c)
544-
if a.itemsize > 1:
540+
if a.itemsize>1:
545541
self.assertRaises(ValueError, b.frombytes, b"x")
546542

547543
def test_fromarray(self):
@@ -910,8 +906,7 @@ def test_setslice(self):
910906
a[1:0] = a
911907
self.assertEqual(
912908
a,
913-
array.array(self.typecode,
914-
self.example[:1] + self.example + self.example[1:])
909+
array.array(self.typecode, self.example[:1] + self.example + self.example[1:])
915910
)
916911

917912
a = array.array(self.typecode, self.example)
@@ -1010,8 +1005,7 @@ def test_pop(self):
10101005
self.assertEntryEqual(a.pop(1), self.example[2])
10111006
self.assertEqual(
10121007
a,
1013-
array.array(self.typecode,
1014-
self.example[1:2]+self.example[3:]+self.example)
1008+
array.array(self.typecode, self.example[1:2]+self.example[3:]+self.example)
10151009
)
10161010
self.assertEntryEqual(a.pop(0), self.example[1])
10171011
self.assertEntryEqual(a.pop(), self.example[-1])
@@ -1217,7 +1211,6 @@ def test_setitem(self):
12171211
a = array.array(self.typecode, self.example)
12181212
self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2])
12191213

1220-
12211214
class UnicodeTest(StringTest, unittest.TestCase):
12221215
typecode = 'u'
12231216
example = '\x01\u263a\x00\ufeff'
@@ -1282,53 +1275,50 @@ class NumberTest(BaseTest):
12821275
def test_extslice(self):
12831276
a = array.array(self.typecode, range(5))
12841277
self.assertEqual(a[::], a)
1285-
self.assertEqual(a[::2], array.array(self.typecode, [0, 2, 4]))
1286-
self.assertEqual(a[1::2], array.array(self.typecode, [1, 3]))
1287-
self.assertEqual(a[::-1], array.array(self.typecode, [4, 3, 2, 1, 0]))
1288-
self.assertEqual(a[::-2], array.array(self.typecode, [4, 2, 0]))
1289-
self.assertEqual(a[3::-2], array.array(self.typecode, [3, 1]))
1278+
self.assertEqual(a[::2], array.array(self.typecode, [0,2,4]))
1279+
self.assertEqual(a[1::2], array.array(self.typecode, [1,3]))
1280+
self.assertEqual(a[::-1], array.array(self.typecode, [4,3,2,1,0]))
1281+
self.assertEqual(a[::-2], array.array(self.typecode, [4,2,0]))
1282+
self.assertEqual(a[3::-2], array.array(self.typecode, [3,1]))
12901283
self.assertEqual(a[-100:100:], a)
12911284
self.assertEqual(a[100:-100:-1], a[::-1])
1292-
self.assertEqual(a[-100:100:2], array.array(self.typecode, [0, 2, 4]))
1285+
self.assertEqual(a[-100:100:2], array.array(self.typecode, [0,2,4]))
12931286
self.assertEqual(a[1000:2000:2], array.array(self.typecode, []))
12941287
self.assertEqual(a[-1000:-2000:-2], array.array(self.typecode, []))
12951288

12961289
def test_delslice(self):
12971290
a = array.array(self.typecode, range(5))
12981291
del a[::2]
1299-
self.assertEqual(a, array.array(self.typecode, [1, 3]))
1292+
self.assertEqual(a, array.array(self.typecode, [1,3]))
13001293
a = array.array(self.typecode, range(5))
13011294
del a[1::2]
1302-
self.assertEqual(a, array.array(self.typecode, [0, 2, 4]))
1295+
self.assertEqual(a, array.array(self.typecode, [0,2,4]))
13031296
a = array.array(self.typecode, range(5))
13041297
del a[1::-2]
1305-
self.assertEqual(a, array.array(self.typecode, [0, 2, 3, 4]))
1298+
self.assertEqual(a, array.array(self.typecode, [0,2,3,4]))
13061299
a = array.array(self.typecode, range(10))
13071300
del a[::1000]
1308-
self.assertEqual(a, array.array(
1309-
self.typecode, [1, 2, 3, 4, 5, 6, 7, 8, 9]))
1301+
self.assertEqual(a, array.array(self.typecode, [1,2,3,4,5,6,7,8,9]))
13101302
# test issue7788
13111303
a = array.array(self.typecode, range(10))
1312-
del a[9::1 << 333]
1304+
del a[9::1<<333]
13131305

13141306
def test_assignment(self):
13151307
a = array.array(self.typecode, range(10))
13161308
a[::2] = array.array(self.typecode, [42]*5)
1317-
self.assertEqual(a, array.array(
1318-
self.typecode, [42, 1, 42, 3, 42, 5, 42, 7, 42, 9]))
1309+
self.assertEqual(a, array.array(self.typecode, [42,1,42,3,42,5,42,7,42,9]))
13191310
a = array.array(self.typecode, range(10))
13201311
a[::-4] = array.array(self.typecode, [10]*3)
1321-
self.assertEqual(a, array.array(
1322-
self.typecode, [0, 10, 2, 3, 4, 10, 6, 7, 8, 10]))
1312+
self.assertEqual(a, array.array(self.typecode, [0,10,2,3,4,10,6,7,8,10]))
13231313
a = array.array(self.typecode, range(4))
13241314
a[::-1] = a
1325-
self.assertEqual(a, array.array(self.typecode, [3, 2, 1, 0]))
1315+
self.assertEqual(a, array.array(self.typecode, [3,2,1,0]))
13261316
a = array.array(self.typecode, range(10))
13271317
b = a[:]
13281318
c = a[:]
13291319
ins = array.array(self.typecode, range(2))
13301320
a[2:3] = ins
1331-
b[slice(2, 3)] = ins
1321+
b[slice(2,3)] = ins
13321322
c[2:3:] = ins
13331323

13341324
def test_iterationcontains(self):
@@ -1379,7 +1369,6 @@ def test_frombytearray(self):
13791369
b = array.array(self.typecode, a)
13801370
self.assertEqual(a, b)
13811371

1382-
13831372
class IntegerNumberTest(NumberTest):
13841373
def test_type_error(self):
13851374
a = array.array(self.typecode)
@@ -1406,7 +1395,6 @@ def __sub__(self, other):
14061395
def __add__(self, other):
14071396
return Intable(int(self) + int(other))
14081397

1409-
14101398
class SignedNumberTest(IntegerNumberTest):
14111399
example = [-1, 0, 1, 42, 0x7f]
14121400
smallerexample = [-1, 0, 1, 42, 0x7e]
@@ -1420,7 +1408,6 @@ def test_overflow(self):
14201408
self.check_overflow(lower, upper)
14211409
self.check_overflow(Intable(lower), Intable(upper))
14221410

1423-
14241411
class UnsignedNumberTest(IntegerNumberTest):
14251412
example = [0, 1, 17, 23, 42, 0xff]
14261413
smallerexample = [0, 1, 17, 23, 42, 0xfe]
@@ -1451,57 +1438,46 @@ def test_bytes_extend(self):
14511438
array.array(self.typecode, self.example+self.example[::-1])
14521439
)
14531440

1454-
14551441
class ByteTest(SignedNumberTest, unittest.TestCase):
14561442
typecode = 'b'
14571443
minitemsize = 1
14581444

1459-
14601445
class UnsignedByteTest(UnsignedNumberTest, unittest.TestCase):
14611446
typecode = 'B'
14621447
minitemsize = 1
14631448

1464-
14651449
class ShortTest(SignedNumberTest, unittest.TestCase):
14661450
typecode = 'h'
14671451
minitemsize = 2
14681452

1469-
14701453
class UnsignedShortTest(UnsignedNumberTest, unittest.TestCase):
14711454
typecode = 'H'
14721455
minitemsize = 2
14731456

1474-
14751457
class IntTest(SignedNumberTest, unittest.TestCase):
14761458
typecode = 'i'
14771459
minitemsize = 2
14781460

1479-
14801461
class UnsignedIntTest(UnsignedNumberTest, unittest.TestCase):
14811462
typecode = 'I'
14821463
minitemsize = 2
14831464

1484-
14851465
class LongTest(SignedNumberTest, unittest.TestCase):
14861466
typecode = 'l'
14871467
minitemsize = 4
14881468

1489-
14901469
class UnsignedLongTest(UnsignedNumberTest, unittest.TestCase):
14911470
typecode = 'L'
14921471
minitemsize = 4
14931472

1494-
14951473
class LongLongTest(SignedNumberTest, unittest.TestCase):
14961474
typecode = 'q'
14971475
minitemsize = 8
14981476

1499-
15001477
class UnsignedLongLongTest(UnsignedNumberTest, unittest.TestCase):
15011478
typecode = 'Q'
15021479
minitemsize = 8
15031480

1504-
15051481
class FPTest(NumberTest):
15061482
example = [-42.0, 0, 42, 1e5, -1e10]
15071483
smallerexample = [-42.0, 0, 42, 1e5, -2e10]
@@ -1527,7 +1503,7 @@ def test_byteswap(self):
15271503
if a.itemsize in (1, 2, 4, 8):
15281504
b = array.array(self.typecode, self.example)
15291505
b.byteswap()
1530-
if a.itemsize == 1:
1506+
if a.itemsize==1:
15311507
self.assertEqual(a, b)
15321508
else:
15331509
# On alphas treating the byte swapped bit patterns as
@@ -1537,12 +1513,10 @@ def test_byteswap(self):
15371513
b.byteswap()
15381514
self.assertEqual(a, b)
15391515

1540-
15411516
class FloatTest(FPTest, unittest.TestCase):
15421517
typecode = 'f'
15431518
minitemsize = 4
15441519

1545-
15461520
class DoubleTest(FPTest, unittest.TestCase):
15471521
typecode = 'd'
15481522
minitemsize = 8
@@ -1556,22 +1530,20 @@ def test_alloc_overflow(self):
15561530
pass
15571531
else:
15581532
self.fail("Array of size > maxsize created - MemoryError expected")
1559-
b = array.array('d', [2.71828183, 3.14159265, -1])
1533+
b = array.array('d', [ 2.71828183, 3.14159265, -1])
15601534
try:
15611535
b * (maxsize//3 + 1)
15621536
except MemoryError:
15631537
pass
15641538
else:
15651539
self.fail("Array of size > maxsize created - MemoryError expected")
15661540

1567-
15681541
class LargeArrayTest(unittest.TestCase):
15691542
typecode = 'b'
15701543

15711544
def example(self, size):
15721545
# We assess a base memuse of <=2.125 for constructing this array
1573-
base = array.array(
1574-
self.typecode, [0, 1, 2, 3, 4, 5, 6, 7]) * (size // 8)
1546+
base = array.array(self.typecode, [0, 1, 2, 3, 4, 5, 6, 7]) * (size // 8)
15751547
base += array.array(self.typecode, [99]*(size % 8) + [8, 9, 10, 11])
15761548
return base
15771549

0 commit comments

Comments
 (0)