From ee1dd76bdc22ed7897950080058c1650e7f580fb Mon Sep 17 00:00:00 2001 From: Peter Hinch Date: Mon, 11 Jun 2018 08:21:55 +0100 Subject: [PATCH] Tests: tidy up printbuf(). --- uasyncio_iostream/tests/iotest1.py | 3 +-- uasyncio_iostream/tests/iotest2.py | 3 +-- uasyncio_iostream/tests/iotest3.py | 3 +-- uasyncio_iostream/tests/iotest4.py | 3 +-- uasyncio_iostream/tests/iotest5.py | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/uasyncio_iostream/tests/iotest1.py b/uasyncio_iostream/tests/iotest1.py index 25c98f3..c46b4b5 100644 --- a/uasyncio_iostream/tests/iotest1.py +++ b/uasyncio_iostream/tests/iotest1.py @@ -11,8 +11,7 @@ MP_STREAM_POLL = const(3) MP_STREAM_ERROR = const(-1) def printbuf(this_io): - for ch in this_io.wbuf[:this_io.wprint_len]: - print(chr(ch), end='') + print(bytes(this_io.wbuf[:this_io.wprint_len]).decode(), end='') class MyIO(io.IOBase): def __init__(self): diff --git a/uasyncio_iostream/tests/iotest2.py b/uasyncio_iostream/tests/iotest2.py index 7dc4605..e538305 100644 --- a/uasyncio_iostream/tests/iotest2.py +++ b/uasyncio_iostream/tests/iotest2.py @@ -12,8 +12,7 @@ MP_STREAM_POLL = const(3) MP_STREAM_ERROR = const(-1) def printbuf(this_io): - for ch in this_io.wbuf[:this_io.wprint_len]: - print(chr(ch), end='') + print(bytes(this_io.wbuf[:this_io.wprint_len]).decode(), end='') this_io.wbuf = b'' class MyIO(io.IOBase): diff --git a/uasyncio_iostream/tests/iotest3.py b/uasyncio_iostream/tests/iotest3.py index 74fa44d..cf1e785 100644 --- a/uasyncio_iostream/tests/iotest3.py +++ b/uasyncio_iostream/tests/iotest3.py @@ -51,8 +51,7 @@ class MyIOR(io.IOBase): # a ready status. For the demo it stores the characters in .wbuf for printing. def printbuf(this_io): - for x in range(this_io.wprint_len): - print(chr(this_io.wbuf[x]), end = '') + print(bytes(this_io.wbuf[:this_io.wprint_len]).decode(), end='') class MyIOW(io.IOBase): def __init__(self): diff --git a/uasyncio_iostream/tests/iotest4.py b/uasyncio_iostream/tests/iotest4.py index d28ea06..6b5c77f 100644 --- a/uasyncio_iostream/tests/iotest4.py +++ b/uasyncio_iostream/tests/iotest4.py @@ -20,8 +20,7 @@ MP_STREAM_POLL = const(3) MP_STREAM_ERROR = const(-1) def printbuf(this_io): - for ch in this_io.wbuf[:this_io.wprint_len]: - print(chr(ch), end='') + print(bytes(this_io.wbuf[:this_io.wprint_len]).decode(), end='') class MyIO(io.IOBase): def __init__(self, read=False, write=False): diff --git a/uasyncio_iostream/tests/iotest5.py b/uasyncio_iostream/tests/iotest5.py index b6b0da5..54e4d73 100644 --- a/uasyncio_iostream/tests/iotest5.py +++ b/uasyncio_iostream/tests/iotest5.py @@ -20,8 +20,7 @@ MP_STREAM_POLL = const(3) MP_STREAM_ERROR = const(-1) def printbuf(this_io): - for ch in this_io.wbuf[:this_io.wprint_len]: - print(chr(ch), end='') + print(bytes(this_io.wbuf[:this_io.wprint_len]).decode(), end='') class MyIO(io.IOBase): def __init__(self, read=False, write=False):