diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-02-01 16:17:22 +0100 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-02-02 12:59:01 +0100 |
commit | ec92d7f67e3c5960d9b30e067fb4ed1ae3fc8884 (patch) | |
tree | 22f48c7eab85ee2e58ac8e7127e198155dbeb62f /mitmproxy/test | |
parent | c1bc1ea584d4bb47c1b754dfa7f10ab4dfc380a3 (diff) | |
download | mitmproxy-ec92d7f67e3c5960d9b30e067fb4ed1ae3fc8884.tar.gz mitmproxy-ec92d7f67e3c5960d9b30e067fb4ed1ae3fc8884.tar.bz2 mitmproxy-ec92d7f67e3c5960d9b30e067fb4ed1ae3fc8884.zip |
cleanup test utils
Diffstat (limited to 'mitmproxy/test')
-rw-r--r-- | mitmproxy/test/tflow.py | 20 | ||||
-rw-r--r-- | mitmproxy/test/tutils.py | 14 |
2 files changed, 27 insertions, 7 deletions
diff --git a/mitmproxy/test/tflow.py b/mitmproxy/test/tflow.py index edf4d7a7..5749bd52 100644 --- a/mitmproxy/test/tflow.py +++ b/mitmproxy/test/tflow.py @@ -115,6 +115,26 @@ def tflow(client_conn=True, server_conn=True, req=True, resp=None, err=None): return f +def tdummyflow(client_conn=True, server_conn=True, err=None): + class DummyFlow(flow.Flow): + """A flow that is neither HTTP nor TCP.""" + + def __init__(self, client_conn, server_conn, live=None): + super().__init__("dummy", client_conn, server_conn, live) + + if client_conn is True: + client_conn = tclient_conn() + if server_conn is True: + server_conn = tserver_conn() + if err is True: + err = terr() + + f = DummyFlow(client_conn, server_conn) + f.error = err + f.reply = controller.DummyReply() + return f + + def tclient_conn(): """ @return: mitmproxy.proxy.connection.ClientConnection diff --git a/mitmproxy/test/tutils.py b/mitmproxy/test/tutils.py index ae0ce2d8..47756315 100644 --- a/mitmproxy/test/tutils.py +++ b/mitmproxy/test/tutils.py @@ -11,12 +11,7 @@ from mitmproxy.net import tcp from mitmproxy.net import http -def treader(bytes): - """ - Construct a tcp.Read object from bytes. - """ - fp = BytesIO(bytes) - return tcp.Reader(fp) +test_data = data.Data(__name__).push("../../test/") @contextmanager @@ -89,7 +84,12 @@ class RaisesContext: return True -test_data = data.Data(__name__).push("../../test/") +def treader(bytes): + """ + Construct a tcp.Read object from bytes. + """ + fp = BytesIO(bytes) + return tcp.Reader(fp) def treq(**kwargs): |