diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-12-03 09:20:27 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-12-08 10:21:05 +1300 |
commit | b231836c70a68daa6016537e5ec18ed7a7cc3b1a (patch) | |
tree | 2b8096070c8d5dd17786281d6e6cfd87b707efa2 /test | |
parent | 297493801ded90ee5b9717115fb2fa25bac43d22 (diff) | |
download | mitmproxy-b231836c70a68daa6016537e5ec18ed7a7cc3b1a.tar.gz mitmproxy-b231836c70a68daa6016537e5ec18ed7a7cc3b1a.tar.bz2 mitmproxy-b231836c70a68daa6016537e5ec18ed7a7cc3b1a.zip |
Get rid of tfile testing option
It's weird, it's ugly, it's getting in the way of my options refactoring, and
it must therefore die.
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_dumper.py | 45 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_termlog.py | 4 |
2 files changed, 22 insertions, 27 deletions
diff --git a/test/mitmproxy/addons/test_dumper.py b/test/mitmproxy/addons/test_dumper.py index 0d61f800..f87df329 100644 --- a/test/mitmproxy/addons/test_dumper.py +++ b/test/mitmproxy/addons/test_dumper.py @@ -28,43 +28,40 @@ def test_configure(): def test_simple(): - d = dumper.Dumper() + sio = io.StringIO() + d = dumper.Dumper(sio) with taddons.context(options=dump.Options()) as ctx: - sio = io.StringIO() - ctx.configure(d, tfile = sio, flow_detail = 0) + ctx.configure(d, flow_detail = 0) d.response(tflow.tflow(resp=True)) assert not sio.getvalue() sio.truncate(0) - ctx.configure(d, tfile = sio, flow_detail = 1) + ctx.configure(d, flow_detail = 1) d.response(tflow.tflow(resp=True)) assert sio.getvalue() sio.truncate(0) - ctx.configure(d, tfile = sio, flow_detail = 1) + ctx.configure(d, flow_detail = 1) d.error(tflow.tflow(err=True)) assert sio.getvalue() sio.truncate(0) - ctx.configure(d, tfile = sio, flow_detail = 4) + ctx.configure(d, flow_detail = 4) d.response(tflow.tflow(resp=True)) assert sio.getvalue() sio.truncate(0) - sio = io.StringIO() - ctx.configure(d, tfile = sio, flow_detail = 4) + ctx.configure(d, flow_detail = 4) d.response(tflow.tflow(resp=True)) assert "<<" in sio.getvalue() sio.truncate(0) - sio = io.StringIO() - ctx.configure(d, tfile = sio, flow_detail = 4) + ctx.configure(d, flow_detail = 4) d.response(tflow.tflow(err=True)) assert "<<" in sio.getvalue() sio.truncate(0) - sio = io.StringIO() - ctx.configure(d, tfile = sio, flow_detail = 4) + ctx.configure(d, flow_detail = 4) flow = tflow.tflow() flow.request = tutils.treq() flow.request.stickycookie = True @@ -77,8 +74,7 @@ def test_simple(): assert sio.getvalue() sio.truncate(0) - sio = io.StringIO() - ctx.configure(d, tfile = sio, flow_detail = 4) + ctx.configure(d, flow_detail = 4) flow = tflow.tflow(resp=tutils.tresp(content=b"{")) flow.response.headers["content-type"] = "application/json" flow.response.status_code = 400 @@ -86,8 +82,7 @@ def test_simple(): assert sio.getvalue() sio.truncate(0) - sio = io.StringIO() - ctx.configure(d, tfile = sio, flow_detail = 4) + ctx.configure(d, flow_detail = 4) flow = tflow.tflow() flow.request.content = None flow.response = http.HTTPResponse.wrap(tutils.tresp()) @@ -102,20 +97,20 @@ def test_echo_body(): f.response.headers["content-type"] = "text/html" f.response.content = b"foo bar voing\n" * 100 - d = dumper.Dumper() sio = io.StringIO() + d = dumper.Dumper(sio) with taddons.context(options=dump.Options()) as ctx: - ctx.configure(d, tfile=sio, flow_detail = 3) + ctx.configure(d, flow_detail = 3) d._echo_message(f.response) t = sio.getvalue() assert "cut off" in t def test_echo_request_line(): - d = dumper.Dumper() sio = io.StringIO() + d = dumper.Dumper(sio) with taddons.context(options=dump.Options()) as ctx: - ctx.configure(d, tfile=sio, flow_detail = 3, showhost = True) + ctx.configure(d, flow_detail = 3, showhost = True) f = tflow.tflow(client_conn=None, server_conn=True, resp=True) f.request.is_replay = True d._echo_request_line(f) @@ -139,19 +134,19 @@ class TestContentView: @mock.patch("mitmproxy.contentviews.ViewAuto.__call__") def test_contentview(self, view_auto): view_auto.side_effect = exceptions.ContentViewException("") - d = dumper.Dumper() + sio = io.StringIO() + d = dumper.Dumper(sio) with taddons.context(options=dump.Options()) as ctx: - sio = io.StringIO() - ctx.configure(d, flow_detail=4, verbosity=3, tfile=sio) + ctx.configure(d, flow_detail=4, verbosity=3) d.response(tflow.tflow()) assert "Content viewer failed" in ctx.master.event_log[0][1] def test_tcp(): - d = dumper.Dumper() sio = io.StringIO() + d = dumper.Dumper(sio) with taddons.context(options=dump.Options()) as ctx: - ctx.configure(d, tfile=sio, flow_detail = 3, showhost = True) + ctx.configure(d, flow_detail = 3, showhost = True) f = tflow.ttcpflow(client_conn=True, server_conn=True) d.tcp_message(f) assert "it's me" in sio.getvalue() diff --git a/test/mitmproxy/addons/test_termlog.py b/test/mitmproxy/addons/test_termlog.py index 880fcb51..d9e18134 100644 --- a/test/mitmproxy/addons/test_termlog.py +++ b/test/mitmproxy/addons/test_termlog.py @@ -7,9 +7,9 @@ from mitmproxy.tools import dump class TestTermLog: def test_simple(self): - t = termlog.TermLog() sio = io.StringIO() - t.configure(dump.Options(tfile = sio, verbosity = 2), set([])) + t = termlog.TermLog(outfile=sio) + t.configure(dump.Options(verbosity = 2), set([])) t.log(log.LogEntry("one", "info")) assert "one" in sio.getvalue() t.log(log.LogEntry("two", "debug")) |