diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/pathod/test_app.py | 3 | ||||
| -rw-r--r-- | test/pathod/test_language_base.py | 8 | ||||
| -rw-r--r-- | test/pathod/test_language_writer.py | 62 | ||||
| -rw-r--r-- | test/pathod/test_pathoc.py | 2 | ||||
| -rw-r--r-- | test/pathod/tutils.py | 4 |
5 files changed, 39 insertions, 40 deletions
diff --git a/test/pathod/test_app.py b/test/pathod/test_app.py index fbaa773c..19888c75 100644 --- a/test/pathod/test_app.py +++ b/test/pathod/test_app.py @@ -32,9 +32,6 @@ class TestApp(tutils.DaemonTests): assert self.getpath("/log/%s" % id).status_code == 200 assert self.getpath("/log/9999999").status_code == 404 - def test_log_binary(self): - assert self.get("200:h@10b=@10b:da") - def test_response_preview(self): r = self.getpath("/response_preview", params=dict(spec="200")) assert r.status_code == 200 diff --git a/test/pathod/test_language_base.py b/test/pathod/test_language_base.py index 47e51bb0..075dc2b8 100644 --- a/test/pathod/test_language_base.py +++ b/test/pathod/test_language_base.py @@ -38,7 +38,7 @@ class TestTokValueNakedLiteral: class TestTokValueLiteral: - def test_espr(self): + def test_expr(self): v = base.TokValueLiteral("foo") assert v.expr() assert v.val == b"foo" @@ -132,7 +132,7 @@ class TestTokValueFile: with tutils.tmpdir() as t: p = os.path.join(t, "path") with open(p, "wb") as f: - f.write("x" * 10000) + f.write(b"x" * 10000) assert v.get_generator(language.Settings(staticdir=t)) @@ -207,13 +207,13 @@ class TestMisc: p = os.path.join(t, "path") s = base.Settings(staticdir=t) with open(p, "wb") as f: - f.write("a" * 20) + f.write(b"a" * 20) v = e.parseString("m<path")[0] tutils.raises("invalid value length", v.values, s) p = os.path.join(t, "path") with open(p, "wb") as f: - f.write("a" * 4) + f.write(b"a" * 4) v = e.parseString("m<path")[0] assert v.values(s) diff --git a/test/pathod/test_language_writer.py b/test/pathod/test_language_writer.py index 0a85524f..c02f66f3 100644 --- a/test/pathod/test_language_writer.py +++ b/test/pathod/test_language_writer.py @@ -1,53 +1,53 @@ -from six.moves import cStringIO as StringIO +from six import BytesIO from pathod import language from pathod.language import writer def test_send_chunk(): - v = "foobarfoobar" + v = b"foobarfoobar" for bs in range(1, len(v) + 2): - s = StringIO() + s = 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 = StringIO() + s = BytesIO() writer.send_chunk(s, v, bs, start, end) assert s.getvalue() == v[start:end] def test_write_values_inject(): - tst = "foo" + tst = b"foo" - s = StringIO() - writer.write_values(s, [tst], [(0, "inject", "aaa")], blocksize=5) - assert s.getvalue() == "aaafoo" + s = BytesIO() + writer.write_values(s, [tst], [(0, "inject", b"aaa")], blocksize=5) + assert s.getvalue() == b"aaafoo" - s = StringIO() - writer.write_values(s, [tst], [(1, "inject", "aaa")], blocksize=5) - assert s.getvalue() == "faaaoo" + s = BytesIO() + writer.write_values(s, [tst], [(1, "inject", b"aaa")], blocksize=5) + assert s.getvalue() == b"faaaoo" - s = StringIO() - writer.write_values(s, [tst], [(1, "inject", "aaa")], blocksize=5) - assert s.getvalue() == "faaaoo" + s = BytesIO() + writer.write_values(s, [tst], [(1, "inject", b"aaa")], blocksize=5) + assert s.getvalue() == b"faaaoo" def test_write_values_disconnects(): - s = StringIO() - tst = "foo" * 100 + s = BytesIO() + tst = b"foo" * 100 writer.write_values(s, [tst], [(0, "disconnect")], blocksize=5) assert not s.getvalue() def test_write_values(): - tst = "foobarvoing" - s = StringIO() + tst = b"foobarvoing" + s = 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 = StringIO() + s = BytesIO() writer.write_values( s, [tst], [(off, "disconnect")], blocksize=bs ) @@ -55,36 +55,36 @@ def test_write_values(): def test_write_values_pauses(): - tst = "".join(str(i) for i in range(10)) + tst = "".join(str(i) for i in range(10)).encode() for i in range(2, 10): - s = StringIO() + s = 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 = StringIO() + s = BytesIO() writer.write_values(s, [tst], [(1, "pause", 0)], blocksize=i) assert s.getvalue() == tst - tst = ["".join(str(i) for i in range(10))] * 5 + tst = [tst] * 5 for i in range(2, 10): - s = StringIO() + s = BytesIO() writer.write_values(s, tst[:], [(1, "pause", 0)], blocksize=i) - assert s.getvalue() == "".join(tst) + assert s.getvalue() == b"".join(tst) def test_write_values_after(): - s = StringIO() - r = language.parse_pathod("400:da").next() + s = BytesIO() + r = next(language.parse_pathod("400:da")) language.serve(r, s, {}) - s = StringIO() - r = language.parse_pathod("400:pa,0").next() + s = BytesIO() + r = next(language.parse_pathod("400:pa,0")) language.serve(r, s, {}) - s = StringIO() - r = language.parse_pathod("400:ia,'xx'").next() + s = BytesIO() + r = next(language.parse_pathod("400:ia,'xx'")) language.serve(r, s, {}) assert s.getvalue().endswith('xx') diff --git a/test/pathod/test_pathoc.py b/test/pathod/test_pathoc.py index 6e36c4bf..18d7f672 100644 --- a/test/pathod/test_pathoc.py +++ b/test/pathod/test_pathoc.py @@ -187,7 +187,7 @@ class TestDaemon(_TestDaemon): def test_showresp_httperr(self): v = self.tval(["get:'/p/200:d20'"], showresp=True, showsummary=True) - assert "Invalid headers" in v + assert "Invalid header" in v assert "HTTP/" in v def test_explain(self): diff --git a/test/pathod/tutils.py b/test/pathod/tutils.py index b9f38d86..1a883c93 100644 --- a/test/pathod/tutils.py +++ b/test/pathod/tutils.py @@ -102,7 +102,9 @@ class DaemonTests(object): fp=logfp, ) with c.connect(): - resp = c.request("get:/p/%s" % urllib.quote(spec).encode("string_escape")) + resp = c.request( + "get:/p/%s" % urllib.quote(spec).encode("string_escape") + ) return resp def pathoc( |
