tests/basics: Split out specific bytearray tests to separate files.
So they can be automatically skipped if bytearray is not enabled.
This commit is contained in:
parent
6e9ba1cf4b
commit
aeea204e98
@ -1,8 +1,6 @@
|
|||||||
# test bytes + other
|
# test bytes + other
|
||||||
|
|
||||||
print(b"123" + b"456")
|
print(b"123" + b"456")
|
||||||
print(b"123" + bytearray(2))
|
|
||||||
|
|
||||||
print(b"123" + b"") # RHS is empty, can be optimised
|
print(b"123" + b"") # RHS is empty, can be optimised
|
||||||
print(b"" + b"123") # LHS is empty, can be optimised
|
print(b"" + b"123") # LHS is empty, can be optimised
|
||||||
print(b"" + bytearray(1)) # LHS is empty but can't be optimised
|
|
||||||
|
5
tests/basics/bytes_add_bytearray.py
Normal file
5
tests/basics/bytes_add_bytearray.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# test bytes + bytearray
|
||||||
|
|
||||||
|
print(b"123" + bytearray(2))
|
||||||
|
|
||||||
|
print(b"" + bytearray(1)) # LHS is empty but can't be optimised
|
@ -1,5 +1 @@
|
|||||||
print(b"1" == 1)
|
print(b"1" == 1)
|
||||||
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")
|
|
||||||
|
4
tests/basics/bytes_compare_bytearray.py
Normal file
4
tests/basics/bytes_compare_bytearray.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
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")
|
@ -1,9 +1,8 @@
|
|||||||
# test construction of bytes from different objects
|
# test construction of bytes from different objects
|
||||||
|
|
||||||
# tuple, list, bytearray
|
# tuple, list
|
||||||
print(bytes((1, 2)))
|
print(bytes((1, 2)))
|
||||||
print(bytes([1, 2]))
|
print(bytes([1, 2]))
|
||||||
print(bytes(bytearray(4)))
|
|
||||||
|
|
||||||
# constructor value out of range
|
# constructor value out of range
|
||||||
try:
|
try:
|
||||||
|
3
tests/basics/bytes_construct_bytearray.py
Normal file
3
tests/basics/bytes_construct_bytearray.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# test construction of bytes from bytearray
|
||||||
|
|
||||||
|
print(bytes(bytearray(4)))
|
@ -13,10 +13,6 @@ try:
|
|||||||
~[]
|
~[]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print('TypeError')
|
print('TypeError')
|
||||||
try:
|
|
||||||
~bytearray()
|
|
||||||
except TypeError:
|
|
||||||
print('TypeError')
|
|
||||||
|
|
||||||
# unsupported binary operators
|
# unsupported binary operators
|
||||||
try:
|
try:
|
||||||
@ -31,16 +27,6 @@ try:
|
|||||||
1 in 1
|
1 in 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print('TypeError')
|
print('TypeError')
|
||||||
try:
|
|
||||||
bytearray() // 2
|
|
||||||
except TypeError:
|
|
||||||
print('TypeError')
|
|
||||||
|
|
||||||
# object with buffer protocol needed on rhs
|
|
||||||
try:
|
|
||||||
bytearray(1) + 1
|
|
||||||
except TypeError:
|
|
||||||
print('TypeError')
|
|
||||||
|
|
||||||
# unsupported subscription
|
# unsupported subscription
|
||||||
try:
|
try:
|
||||||
|
19
tests/basics/op_error_bytearray.py
Normal file
19
tests/basics/op_error_bytearray.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# test errors from bad operations (unary, binary, etc)
|
||||||
|
|
||||||
|
# unsupported unary operators
|
||||||
|
try:
|
||||||
|
~bytearray()
|
||||||
|
except TypeError:
|
||||||
|
print('TypeError')
|
||||||
|
|
||||||
|
# unsupported binary operators
|
||||||
|
try:
|
||||||
|
bytearray() // 2
|
||||||
|
except TypeError:
|
||||||
|
print('TypeError')
|
||||||
|
|
||||||
|
# object with buffer protocol needed on rhs
|
||||||
|
try:
|
||||||
|
bytearray(1) + 1
|
||||||
|
except TypeError:
|
||||||
|
print('TypeError')
|
Loading…
x
Reference in New Issue
Block a user