diff --git a/tests/basics/builtin_property.py b/tests/basics/builtin_property.py index 403abd62f4..ff4ff073c4 100644 --- a/tests/basics/builtin_property.py +++ b/tests/basics/builtin_property.py @@ -1,4 +1,10 @@ # test builtin property +try: + property +except: + import sys + print("SKIP") + sys.exit() # create a property object explicitly property() diff --git a/tests/basics/builtin_sorted.py b/tests/basics/builtin_sorted.py index a4f71a15eb..68855b61ba 100644 --- a/tests/basics/builtin_sorted.py +++ b/tests/basics/builtin_sorted.py @@ -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))) diff --git a/tests/basics/bytearray_construct.py b/tests/basics/bytearray_construct.py index 1c45f6fcf5..9c8f3adaaa 100644 --- a/tests/basics/bytearray_construct.py +++ b/tests/basics/bytearray_construct.py @@ -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]))) diff --git a/tests/basics/bytearray_construct_array.py b/tests/basics/bytearray_construct_array.py new file mode 100644 index 0000000000..6d45cafda3 --- /dev/null +++ b/tests/basics/bytearray_construct_array.py @@ -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]))) diff --git a/tests/basics/bytearray_construct_endian.py b/tests/basics/bytearray_construct_endian.py index dbd635c0c9..f68f9b89d1 100644 --- a/tests/basics/bytearray_construct_endian.py +++ b/tests/basics/bytearray_construct_endian.py @@ -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]))) diff --git a/tests/basics/bytes_add.py b/tests/basics/bytes_add.py index 7a887db231..5432d01e58 100644 --- a/tests/basics/bytes_add.py +++ b/tests/basics/bytes_add.py @@ -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])) diff --git a/tests/basics/bytes_add_array.py b/tests/basics/bytes_add_array.py new file mode 100644 index 0000000000..2b8cbccef5 --- /dev/null +++ b/tests/basics/bytes_add_array.py @@ -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])) diff --git a/tests/basics/bytes_add_endian.py b/tests/basics/bytes_add_endian.py index 5471280d93..1bbd0f2c3a 100644 --- a/tests/basics/bytes_add_endian.py +++ b/tests/basics/bytes_add_endian.py @@ -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])) diff --git a/tests/basics/bytes_compare2.py b/tests/basics/bytes_compare2.py index 8959da3ae7..4d5de21d21 100644 --- a/tests/basics/bytes_compare2.py +++ b/tests/basics/bytes_compare2.py @@ -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])) diff --git a/tests/basics/bytes_compare_array.py b/tests/basics/bytes_compare_array.py new file mode 100644 index 0000000000..ad41d1d375 --- /dev/null +++ b/tests/basics/bytes_compare_array.py @@ -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])) diff --git a/tests/basics/bytes_construct.py b/tests/basics/bytes_construct.py index 1647387675..0d638c08f2 100644 --- a/tests/basics/bytes_construct.py +++ b/tests/basics/bytes_construct.py @@ -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]) diff --git a/tests/basics/bytes_construct_array.py b/tests/basics/bytes_construct_array.py new file mode 100644 index 0000000000..72c2d0c585 --- /dev/null +++ b/tests/basics/bytes_construct_array.py @@ -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]))) diff --git a/tests/basics/bytes_construct_endian.py b/tests/basics/bytes_construct_endian.py index 1912f63a4d..77e0eaaa56 100644 --- a/tests/basics/bytes_construct_endian.py +++ b/tests/basics/bytes_construct_endian.py @@ -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])))