diff options
author | Rachel Dowdall <rjdowdall@gmail.com> | 2014-03-22 12:17:36 +0000 |
---|---|---|
committer | Rachel Dowdall <rjdowdall@gmail.com> | 2014-03-22 12:17:36 +0000 |
commit | 17f45d41fefdb75fb76fca00ce4d7d5e158b6ea5 (patch) | |
tree | 36077e73d30aa91f94ed74b707facc86b7ed7937 /tests/basics/bytes.py | |
parent | 300c8bd4c2c0c6d626a6aaeb873c22a8f8b9fc3f (diff) | |
parent | da8d21e0dd236ae5e31bfac4ff8d5b73ddd49282 (diff) | |
download | micropython-17f45d41fefdb75fb76fca00ce4d7d5e158b6ea5.tar.gz micropython-17f45d41fefdb75fb76fca00ce4d7d5e158b6ea5.zip |
Merge remote-tracking branch 'upstream/master'
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())) |