diff options
author | Damien George <damien.p.george@gmail.com> | 2014-03-21 23:32:59 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-03-21 23:32:59 +0000 |
commit | b32db4e1ad381edaaf91320cb2830e4a1b151863 (patch) | |
tree | c31e254cef1b73aa19bba253ba78ec5375b3b656 /tests/basics/bytes.py | |
parent | 8913c04831c94d2bcb82b0447ab7ccf6b2e346a6 (diff) | |
parent | 093b8a5fa62b4403d56d4323fe1a088dbe9f7efe (diff) | |
download | micropython-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.py | 28 |
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())) |