diff options
Diffstat (limited to 'test/pathod/test_language_writer.py')
-rw-r--r-- | test/pathod/test_language_writer.py | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/test/pathod/test_language_writer.py b/test/pathod/test_language_writer.py index e857e084..7feb985d 100644 --- a/test/pathod/test_language_writer.py +++ b/test/pathod/test_language_writer.py @@ -1,4 +1,4 @@ -from six import BytesIO +import io from pathod import language from pathod.language import writer @@ -6,12 +6,12 @@ from pathod.language import writer def test_send_chunk(): v = b"foobarfoobar" for bs in range(1, len(v) + 2): - s = BytesIO() + s = io.BytesIO() writer.send_chunk(s, v, bs, 0, len(v)) assert s.getvalue() == v for start in range(len(v)): for end in range(len(v)): - s = BytesIO() + s = io.BytesIO() writer.send_chunk(s, v, bs, start, end) assert s.getvalue() == v[start:end] @@ -19,21 +19,21 @@ def test_send_chunk(): def test_write_values_inject(): tst = b"foo" - s = BytesIO() + s = io.BytesIO() writer.write_values(s, [tst], [(0, "inject", b"aaa")], blocksize=5) assert s.getvalue() == b"aaafoo" - s = BytesIO() + s = io.BytesIO() writer.write_values(s, [tst], [(1, "inject", b"aaa")], blocksize=5) assert s.getvalue() == b"faaaoo" - s = BytesIO() + s = io.BytesIO() writer.write_values(s, [tst], [(1, "inject", b"aaa")], blocksize=5) assert s.getvalue() == b"faaaoo" def test_write_values_disconnects(): - s = BytesIO() + s = io.BytesIO() tst = b"foo" * 100 writer.write_values(s, [tst], [(0, "disconnect")], blocksize=5) assert not s.getvalue() @@ -41,13 +41,13 @@ def test_write_values_disconnects(): def test_write_values(): tst = b"foobarvoing" - s = BytesIO() + s = io.BytesIO() writer.write_values(s, [tst], []) assert s.getvalue() == tst for bs in range(1, len(tst) + 2): for off in range(len(tst)): - s = BytesIO() + s = io.BytesIO() writer.write_values( s, [tst], [(off, "disconnect")], blocksize=bs ) @@ -57,34 +57,34 @@ def test_write_values(): def test_write_values_pauses(): tst = "".join(str(i) for i in range(10)).encode() for i in range(2, 10): - s = BytesIO() + s = io.BytesIO() writer.write_values( s, [tst], [(2, "pause", 0), (1, "pause", 0)], blocksize=i ) assert s.getvalue() == tst for i in range(2, 10): - s = BytesIO() + s = io.BytesIO() writer.write_values(s, [tst], [(1, "pause", 0)], blocksize=i) assert s.getvalue() == tst tst = [tst] * 5 for i in range(2, 10): - s = BytesIO() + s = io.BytesIO() writer.write_values(s, tst[:], [(1, "pause", 0)], blocksize=i) assert s.getvalue() == b"".join(tst) def test_write_values_after(): - s = BytesIO() + s = io.BytesIO() r = next(language.parse_pathod("400:da")) language.serve(r, s, {}) - s = BytesIO() + s = io.BytesIO() r = next(language.parse_pathod("400:pa,0")) language.serve(r, s, {}) - s = BytesIO() + s = io.BytesIO() r = next(language.parse_pathod("400:ia,'xx'")) language.serve(r, s, {}) assert s.getvalue().endswith(b'xx') |