Skip to content

Commit 58d9b10

Browse files
committed
tests: Split byteorder-dependent tests to *_endian.py's.
1 parent 0a8b5d1 commit 58d9b10

8 files changed

Lines changed: 31 additions & 6 deletions

tests/basics/array_construct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
print(array('h', [1, 2]))
88

99
# raw copy from bytes, bytearray
10-
print(array('h', b'12'))
10+
print(array('h', b'22')) # should be byteorder-neutral
1111
print(array('h', bytearray(2)))
1212
print(array('i', bytearray(4)))
1313

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# test construction of array.array from different objects
2+
3+
from array import array
4+
5+
# raw copy from bytes, bytearray
6+
print(array('h', b'12'))

tests/basics/bytearray_construct.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99

1010
# arrays
1111
print(bytearray(array('b', [1, 2])))
12-
print(bytearray(array('h', [1, 2])))
13-
print(bytearray(array('I', [1, 2])))
12+
print(bytearray(array('h', [0x101, 0x202])))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# test construction of bytearray from different objects
2+
3+
from array import array
4+
5+
# arrays
6+
print(bytearray(array('h', [1, 2])))
7+
print(bytearray(array('I', [1, 2])))

tests/basics/bytes_add.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55

66
import array
77

8-
print(b"123" + array.array('i', [1]))
8+
# should be byteorder-neutral
9+
print(b"123" + array.array('h', [0x1515]))
10+
911
print(b"\x01\x02" + array.array('b', [1, 2]))

tests/basics/bytes_add_endian.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# test bytes + other
2+
3+
import array
4+
5+
print(b"123" + array.array('i', [1]))

tests/basics/bytes_construct.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
# arrays
1111
print(bytes(array('b', [1, 2])))
12-
print(bytes(array('h', [1, 2])))
13-
print(bytes(array('I', [1, 2])))
12+
print(bytes(array('h', [0x101, 0x202])))
1413

1514
# long ints
1615
print(ord(bytes([14953042807679334000 & 0xff])))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# test construction of bytes from different objects
2+
3+
from array import array
4+
5+
# arrays
6+
print(bytes(array('h', [1, 2])))
7+
print(bytes(array('I', [1, 2])))

0 commit comments

Comments
 (0)