forked from Lephenixnoir/PythonExtra
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
|
||||
|
||||
print(b"123" + b"456")
|
||||
print(b"123" + bytearray(2))
|
||||
|
||||
print(b"123" + b"") # RHS 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
|
||||
|
|
|
@ -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"123" == bytearray(b"123"))
|
||||
print(b'123' < bytearray(b"124"))
|
||||
print(b'123' > bytearray(b"122"))
|
||||
print(bytearray(b"23") in b"1234")
|
||||
|
|
|
@ -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
|
||||
|
||||
# tuple, list, bytearray
|
||||
# tuple, list
|
||||
print(bytes((1, 2)))
|
||||
print(bytes([1, 2]))
|
||||
print(bytes(bytearray(4)))
|
||||
|
||||
# constructor value out of range
|
||||
try:
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
# test construction of bytes from bytearray
|
||||
|
||||
print(bytes(bytearray(4)))
|
|
@ -13,10 +13,6 @@ try:
|
|||
~[]
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
try:
|
||||
~bytearray()
|
||||
except TypeError:
|
||||
print('TypeError')
|
||||
|
||||
# unsupported binary operators
|
||||
try:
|
||||
|
@ -31,16 +27,6 @@ try:
|
|||
1 in 1
|
||||
except 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
|
||||
try:
|
||||
|
|
|
@ -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…
Reference in New Issue