summaryrefslogtreecommitdiff
path: root/tests/basics/bytearray_construct.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/bytearray_construct.py')
-rw-r--r--tests/basics/bytearray_construct.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/basics/bytearray_construct.py b/tests/basics/bytearray_construct.py
new file mode 100644
index 000000000..0a7097d55
--- /dev/null
+++ b/tests/basics/bytearray_construct.py
@@ -0,0 +1,14 @@
+# 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', [1, 2])))
+print(bytearray(array('I', [1, 2])))
+print(bytearray(array('f', [1, 2.3])))