diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-03-21 23:46:59 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-03-22 00:07:04 +0200 |
commit | 1ecea7c7539e73f105fef25da8a3bde7783da755 (patch) | |
tree | 9d68bba4d27aec7d752501dedea2fb1e56569d54 /tests | |
parent | be020c27a870feff9773c348fa04be8c54873f70 (diff) | |
download | micropython-1ecea7c7539e73f105fef25da8a3bde7783da755.tar.gz micropython-1ecea7c7539e73f105fef25da8a3bde7783da755.zip |
py: Make 'bytes' be a proper type, support standard constructor args.
Diffstat (limited to 'tests')
-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())) |