summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/bytes.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-03-21 23:32:59 +0000
committerDamien George <damien.p.george@gmail.com>2014-03-21 23:32:59 +0000
commitb32db4e1ad381edaaf91320cb2830e4a1b151863 (patch)
treec31e254cef1b73aa19bba253ba78ec5375b3b656 /tests/basics/bytes.py
parent8913c04831c94d2bcb82b0447ab7ccf6b2e346a6 (diff)
parent093b8a5fa62b4403d56d4323fe1a088dbe9f7efe (diff)
downloadmicropython-b32db4e1ad381edaaf91320cb2830e4a1b151863.tar.gz
micropython-b32db4e1ad381edaaf91320cb2830e4a1b151863.zip
Merge branch 'master' of github.com:micropython/micropython
Diffstat (limited to 'tests/basics/bytes.py')
-rw-r--r--tests/basics/bytes.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/basics/bytes.py b/tests/basics/bytes.py
index 7d0cf22d44..a084bc3994 100644
--- a/tests/basics/bytes.py
+++ b/tests/basics/bytes.py
@@ -4,8 +4,36 @@ print(str(a))
print(repr(a))
print(a[0], a[2])
print(a[-1])
+print(str(a, "utf-8"))
+print(str(a, "utf-8", "ignore"))
+try:
+ str(a, "utf-8", "ignore", "toomuch")
+except TypeError:
+ print("TypeError")
s = 0
for i in a:
s += i
print(s)
+
+
+print(bytes("abc", "utf-8"))
+print(bytes("abc", "utf-8", "replace"))
+try:
+ bytes("abc")
+except TypeError:
+ print("TypeError")
+try:
+ bytes("abc", "utf-8", "replace", "toomuch")
+except TypeError:
+ print("TypeError")
+
+print(bytes(3))
+
+print(bytes([3, 2, 1]))
+print(bytes(range(5)))
+
+def gen():
+ for i in range(4):
+ yield i
+print(bytes(gen()))