diff options
Diffstat (limited to 'test/pathod')
-rw-r--r-- | test/pathod/test_language_actions.py | 4 | ||||
-rw-r--r-- | test/pathod/test_language_http.py | 16 | ||||
-rw-r--r-- | test/pathod/test_language_http2.py | 16 | ||||
-rw-r--r-- | test/pathod/test_language_writer.py | 30 | ||||
-rw-r--r-- | test/pathod/test_log.py | 6 | ||||
-rw-r--r-- | test/pathod/test_pathoc.py | 15 | ||||
-rw-r--r-- | test/pathod/test_pathoc_cmdline.py | 4 | ||||
-rw-r--r-- | test/pathod/test_pathod.py | 4 | ||||
-rw-r--r-- | test/pathod/tutils.py | 15 |
9 files changed, 54 insertions, 56 deletions
diff --git a/test/pathod/test_language_actions.py b/test/pathod/test_language_actions.py index 2b1b6915..9740e5c7 100644 --- a/test/pathod/test_language_actions.py +++ b/test/pathod/test_language_actions.py @@ -1,4 +1,4 @@ -from six import BytesIO +import io from pathod.language import actions, parse_pathoc, parse_pathod, serve @@ -60,7 +60,7 @@ class TestInject: assert v.offset == "r" def test_serve(self): - s = BytesIO() + s = io.BytesIO() r = next(parse_pathod("400:i0,'foo'")) assert serve(r, s, {}) diff --git a/test/pathod/test_language_http.py b/test/pathod/test_language_http.py index dd0b8d02..e1eabe4a 100644 --- a/test/pathod/test_language_http.py +++ b/test/pathod/test_language_http.py @@ -1,4 +1,4 @@ -from six import BytesIO +import io from pathod import language from pathod.language import http, base @@ -10,7 +10,7 @@ def parse_request(s): def test_make_error_response(): - d = BytesIO() + d = io.BytesIO() s = http.make_error_response("foo") language.serve(s, d, {}) @@ -76,7 +76,7 @@ class TestRequest: assert r[0].values({}) def test_render(self): - s = BytesIO() + s = io.BytesIO() r = parse_request("GET:'/foo'") assert language.serve( r, @@ -163,7 +163,7 @@ class TestResponse: assert b"OK" in [i[:] for i in r.preamble({})] def test_render(self): - s = BytesIO() + s = io.BytesIO() r = next(language.parse_pathod("400:m'msg'")) assert language.serve(r, s, {}) @@ -173,13 +173,13 @@ class TestResponse: assert "p0" not in s.spec() def test_raw(self): - s = BytesIO() + s = io.BytesIO() r = next(language.parse_pathod("400:b'foo'")) language.serve(r, s, {}) v = s.getvalue() assert b"Content-Length" in v - s = BytesIO() + s = io.BytesIO() r = next(language.parse_pathod("400:b'foo':r")) language.serve(r, s, {}) v = s.getvalue() @@ -187,7 +187,7 @@ class TestResponse: def test_length(self): def testlen(x): - s = BytesIO() + s = io.BytesIO() x = next(x) language.serve(x, s, language.Settings()) assert x.length(language.Settings()) == len(s.getvalue()) @@ -198,7 +198,7 @@ class TestResponse: def test_maximum_length(self): def testlen(x): x = next(x) - s = BytesIO() + s = io.BytesIO() m = x.maximum_length({}) language.serve(x, s, {}) assert m >= len(s.getvalue()) diff --git a/test/pathod/test_language_http2.py b/test/pathod/test_language_http2.py index f4b34047..11e100ac 100644 --- a/test/pathod/test_language_http2.py +++ b/test/pathod/test_language_http2.py @@ -1,4 +1,4 @@ -from six import BytesIO +import io from netlib import tcp from netlib.http import user_agents @@ -26,7 +26,7 @@ def default_settings(): def test_make_error_response(): - d = BytesIO() + d = io.BytesIO() s = http2.make_error_response("foo", "bar") language.serve(s, d, default_settings()) @@ -85,7 +85,7 @@ class TestRequest: assert r[1].method.string() == b"GET" def test_render_simple(self): - s = BytesIO() + s = io.BytesIO() r = parse_request("GET:'/foo'") assert language.serve( r, @@ -127,7 +127,7 @@ class TestRequest: assert r.headers[0].values(default_settings()) == (b"user-agent", user_agents.get_by_shortcut('a')[2].encode()) def test_render_with_headers(self): - s = BytesIO() + s = io.BytesIO() r = parse_request('GET:/foo:h"foo"="bar"') assert language.serve( r, @@ -143,7 +143,7 @@ class TestRequest: assert r.values(default_settings()) def test_render_with_body(self): - s = BytesIO() + s = io.BytesIO() r = parse_request("GET:'/foo':bfoobar") assert language.serve( r, @@ -200,7 +200,7 @@ class TestResponse: assert r.body.string() == b"foobar" def test_render_simple(self): - s = BytesIO() + s = io.BytesIO() r = parse_response('200') assert language.serve( r, @@ -209,7 +209,7 @@ class TestResponse: ) def test_render_with_headers(self): - s = BytesIO() + s = io.BytesIO() r = parse_response('200:h"foo"="bar"') assert language.serve( r, @@ -218,7 +218,7 @@ class TestResponse: ) def test_render_with_body(self): - s = BytesIO() + s = io.BytesIO() r = parse_response('200:bfoobar') assert language.serve( r, 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') diff --git a/test/pathod/test_log.py b/test/pathod/test_log.py index 0cd5b3b0..deb0f613 100644 --- a/test/pathod/test_log.py +++ b/test/pathod/test_log.py @@ -1,10 +1,10 @@ +import io + from pathod import log from netlib.exceptions import TcpDisconnect -import six - -class DummyIO(six.StringIO): +class DummyIO(io.StringIO): def start_log(self, *args, **kwargs): pass diff --git a/test/pathod/test_pathoc.py b/test/pathod/test_pathoc.py index 361a863b..f9670d73 100644 --- a/test/pathod/test_pathoc.py +++ b/test/pathod/test_pathoc.py @@ -1,5 +1,4 @@ -from six.moves import cStringIO as StringIO -from six import BytesIO +import io from mock import Mock from netlib import http @@ -21,7 +20,7 @@ def test_response(): class PathocTestDaemon(tutils.DaemonTests): def tval(self, requests, timeout=None, showssl=False, **kwargs): - s = StringIO() + s = io.StringIO() c = pathoc.Pathoc( ("127.0.0.1", self.d.port), ssl=self.ssl, @@ -71,7 +70,7 @@ class TestDaemonSSL(PathocTestDaemon): assert log[0]["request"]["clientcert"]["keyinfo"] def test_http2_without_ssl(self): - fp = StringIO() + fp = io.StringIO() c = pathoc.Pathoc( ("127.0.0.1", self.d.port), use_http2=True, @@ -171,15 +170,15 @@ class TestDaemon(PathocTestDaemon): def test_connect_fail(self): to = ("foobar", 80) c = pathoc.Pathoc(("127.0.0.1", self.d.port), fp=None) - c.rfile, c.wfile = BytesIO(), BytesIO() + c.rfile, c.wfile = io.BytesIO(), io.BytesIO() with raises("connect failed"): c.http_connect(to) - c.rfile = BytesIO( + c.rfile = io.BytesIO( b"HTTP/1.1 500 OK\r\n" ) with raises("connect failed"): c.http_connect(to) - c.rfile = BytesIO( + c.rfile = io.BytesIO( b"HTTP/1.1 200 OK\r\n" ) c.http_connect(to) @@ -187,7 +186,7 @@ class TestDaemon(PathocTestDaemon): def test_socks_connect(self): to = ("foobar", 80) c = pathoc.Pathoc(("127.0.0.1", self.d.port), fp=None) - c.rfile, c.wfile = tutils.treader(b""), BytesIO() + c.rfile, c.wfile = tutils.treader(b""), io.BytesIO() tutils.raises(pathoc.PathocError, c.socks_connect, to) c.rfile = tutils.treader( diff --git a/test/pathod/test_pathoc_cmdline.py b/test/pathod/test_pathoc_cmdline.py index 922cf3a9..7f51929f 100644 --- a/test/pathod/test_pathoc_cmdline.py +++ b/test/pathod/test_pathoc_cmdline.py @@ -1,4 +1,4 @@ -from six.moves import cStringIO as StringIO +import io import mock from pathod import pathoc_cmdline as cmdline @@ -9,7 +9,7 @@ from . import tutils @mock.patch("argparse.ArgumentParser.error") def test_pathoc(perror): assert cmdline.args_pathoc(["pathoc", "foo.com", "get:/"]) - s = StringIO() + s = io.StringIO() with tutils.raises(SystemExit): cmdline.args_pathoc(["pathoc", "--show-uas"], s, s) diff --git a/test/pathod/test_pathod.py b/test/pathod/test_pathod.py index 0b34f924..d119348a 100644 --- a/test/pathod/test_pathod.py +++ b/test/pathod/test_pathod.py @@ -1,4 +1,4 @@ -from six.moves import cStringIO as StringIO +import io from pathod import pathod from netlib import tcp @@ -10,7 +10,7 @@ from . import tutils class TestPathod(object): def test_logging(self): - s = StringIO() + s = io.StringIO() p = pathod.Pathod(("127.0.0.1", 0), logfp=s) assert len(p.get_log()) == 0 id = p.add_log(dict(s="foo")) diff --git a/test/pathod/tutils.py b/test/pathod/tutils.py index 3a94b6eb..518485ba 100644 --- a/test/pathod/tutils.py +++ b/test/pathod/tutils.py @@ -2,9 +2,8 @@ import tempfile import re import shutil import requests -from six.moves import cStringIO as StringIO -from six.moves import urllib -from six import BytesIO +import io +import urllib from netlib import tcp from netlib import utils @@ -20,7 +19,7 @@ def treader(bytes): """ Construct a tcp.Read object from bytes. """ - fp = BytesIO(bytes) + fp = io.BytesIO(bytes) return tcp.Reader(fp) @@ -79,7 +78,7 @@ class DaemonTests(object): return resp def getpath(self, path, params=None): - logfp = StringIO() + logfp = io.StringIO() c = pathoc.Pathoc( ("localhost", self.d.port), ssl=self.ssl, @@ -92,7 +91,7 @@ class DaemonTests(object): return resp def get(self, spec): - logfp = StringIO() + logfp = io.StringIO() c = pathoc.Pathoc( ("localhost", self.d.port), ssl=self.ssl, @@ -118,7 +117,7 @@ class DaemonTests(object): """ if ssl is None: ssl = self.ssl - logfp = StringIO() + logfp = io.StringIO() c = pathoc.Pathoc( ("localhost", self.d.port), ssl=ssl, @@ -148,6 +147,6 @@ test_data = utils.Data(__name__) def render(r, settings=language.Settings()): r = r.resolve(settings) - s = BytesIO() + s = io.BytesIO() assert language.serve(r, s, settings) return s.getvalue() |