summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-10-29 21:24:51 +1100
committerDamien George <damien.p.george@gmail.com>2019-10-29 22:22:37 +1100
commitaeea204e9802d6a175d94bdb03de428b5f1c74d1 (patch)
tree3d8dddf43d10a5b063df4f4ab934d347783f83a0
parent6e9ba1cf4b0cd8e2986e9abe9a8a66c43a43c63a (diff)
tests/basics: Split out specific bytearray tests to separate files.
So they can be automatically skipped if bytearray is not enabled.
-rw-r--r--tests/basics/bytes_add.py2
-rw-r--r--tests/basics/bytes_add_bytearray.py5
-rw-r--r--tests/basics/bytes_compare2.py4
-rw-r--r--tests/basics/bytes_compare_bytearray.py4
-rw-r--r--tests/basics/bytes_construct.py3
-rw-r--r--tests/basics/bytes_construct_bytearray.py3
-rw-r--r--tests/basics/op_error.py14
-rw-r--r--tests/basics/op_error_bytearray.py19
8 files changed, 32 insertions, 22 deletions
diff --git a/tests/basics/bytes_add.py b/tests/basics/bytes_add.py
index ebccf0662..ab027a26d 100644
--- a/tests/basics/bytes_add.py
+++ b/tests/basics/bytes_add.py
@@ -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
diff --git a/tests/basics/bytes_add_bytearray.py b/tests/basics/bytes_add_bytearray.py
new file mode 100644
index 000000000..4998800b5
--- /dev/null
+++ b/tests/basics/bytes_add_bytearray.py
@@ -0,0 +1,5 @@
+# test bytes + bytearray
+
+print(b"123" + bytearray(2))
+
+print(b"" + bytearray(1)) # LHS is empty but can't be optimised
diff --git a/tests/basics/bytes_compare2.py b/tests/basics/bytes_compare2.py
index 4d5de21d2..855968537 100644
--- a/tests/basics/bytes_compare2.py
+++ b/tests/basics/bytes_compare2.py
@@ -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")
diff --git a/tests/basics/bytes_compare_bytearray.py b/tests/basics/bytes_compare_bytearray.py
new file mode 100644
index 000000000..6a8d8b8a5
--- /dev/null
+++ b/tests/basics/bytes_compare_bytearray.py
@@ -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")
diff --git a/tests/basics/bytes_construct.py b/tests/basics/bytes_construct.py
index 0d638c08f..6f83f1cb2 100644
--- a/tests/basics/bytes_construct.py
+++ b/tests/basics/bytes_construct.py
@@ -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:
diff --git a/tests/basics/bytes_construct_bytearray.py b/tests/basics/bytes_construct_bytearray.py
new file mode 100644
index 000000000..75f08acd3
--- /dev/null
+++ b/tests/basics/bytes_construct_bytearray.py
@@ -0,0 +1,3 @@
+# test construction of bytes from bytearray
+
+print(bytes(bytearray(4)))
diff --git a/tests/basics/op_error.py b/tests/basics/op_error.py
index 7b4f896e1..63c35db3f 100644
--- a/tests/basics/op_error.py
+++ b/tests/basics/op_error.py
@@ -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:
diff --git a/tests/basics/op_error_bytearray.py b/tests/basics/op_error_bytearray.py
new file mode 100644
index 000000000..9ab69371d
--- /dev/null
+++ b/tests/basics/op_error_bytearray.py
@@ -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')