tests/basic: Make various tests skippable.

This commit is contained in:
Paul Sokolovsky 2017-03-09 00:07:19 +01:00
parent 52b6764894
commit 983144404b
13 changed files with 75 additions and 30 deletions

View File

@ -1,4 +1,10 @@
# test builtin property
try:
property
except:
import sys
print("SKIP")
sys.exit()
# create a property object explicitly
property()

View File

@ -1,4 +1,11 @@
# test builtin sorted
try:
sorted
set
except:
import sys
print("SKIP")
sys.exit()
print(sorted(set(range(100))))
print(sorted(set(range(100)), key=lambda x: x + 100*(x % 2)))

View File

@ -1,12 +1,6 @@
# test construction of bytearray from different objects
from array import array
# bytes, tuple, list
print(bytearray(b'123'))
print(bytearray((1, 2)))
print(bytearray([1, 2]))
# arrays
print(bytearray(array('b', [1, 2])))
print(bytearray(array('h', [0x101, 0x202])))

View File

@ -0,0 +1,11 @@
# test construction of bytearray from different objects
try:
from array import array
except ImportError:
import sys
print("SKIP")
sys.exit()
# arrays
print(bytearray(array('b', [1, 2])))
print(bytearray(array('h', [0x101, 0x202])))

View File

@ -1,6 +1,10 @@
# test construction of bytearray from different objects
from array import array
try:
from array import array
except ImportError:
import sys
print("SKIP")
sys.exit()
# arrays
print(bytearray(array('h', [1, 2])))

View File

@ -2,10 +2,3 @@
print(b"123" + b"456")
print(b"123" + bytearray(2))
import array
# should be byteorder-neutral
print(b"123" + array.array('h', [0x1515]))
print(b"\x01\x02" + array.array('b', [1, 2]))

View File

@ -0,0 +1,12 @@
# test bytes + other
try:
import array
except ImportError:
import sys
print("SKIP")
sys.exit()
# should be byteorder-neutral
print(b"123" + array.array('h', [0x1515]))
print(b"\x01\x02" + array.array('b', [1, 2]))

View File

@ -1,5 +1,9 @@
# test bytes + other
import array
try:
import array
except ImportError:
import sys
print("SKIP")
sys.exit()
print(b"123" + array.array('i', [1]))

View File

@ -3,9 +3,3 @@ print(b"123" == bytearray(b"123"))
print(b'123' < bytearray(b"124"))
print(b'123' > bytearray(b"122"))
print(bytearray(b"23") in b"1234")
import array
print(array.array('b', [1, 2]) in b'\x01\x02\x03')
# CPython gives False here
#print(b"\x01\x02\x03" == array.array("B", [1, 2, 3]))

View File

@ -0,0 +1,10 @@
try:
import array
except ImportError:
import sys
print("SKIP")
sys.exit()
print(array.array('b', [1, 2]) in b'\x01\x02\x03')
# CPython gives False here
#print(b"\x01\x02\x03" == array.array("B", [1, 2, 3]))

View File

@ -1,16 +1,10 @@
# test construction of bytes from different objects
from array import array
# tuple, list, bytearray
print(bytes((1, 2)))
print(bytes([1, 2]))
print(bytes(bytearray(4)))
# arrays
print(bytes(array('b', [1, 2])))
print(bytes(array('h', [0x101, 0x202])))
# constructor value out of range
try:
bytes([-1])

View File

@ -0,0 +1,11 @@
# test construction of bytes from different objects
try:
from array import array
except ImportError:
import sys
print("SKIP")
sys.exit()
# arrays
print(bytes(array('b', [1, 2])))
print(bytes(array('h', [0x101, 0x202])))

View File

@ -1,6 +1,11 @@
# test construction of bytes from different objects
from array import array
try:
from array import array
except ImportError:
import sys
print("SKIP")
sys.exit()
# arrays
print(bytes(array('h', [1, 2])))