diff options
author | Maximilian Hils <git@maximilianhils.com> | 2018-11-09 08:58:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-09 08:58:41 +0100 |
commit | 3f3ed4743a3dda8901a35aa14d8e1c689933a1a4 (patch) | |
tree | 3e980de5aca3369b04a8f681f46b20098b7dd762 /test | |
parent | ef485fa5cc83ec29dc502011013957408a084885 (diff) | |
parent | fd1efc885236f41a2d427ede40a7f7ae272ae319 (diff) | |
download | mitmproxy-3f3ed4743a3dda8901a35aa14d8e1c689933a1a4.tar.gz mitmproxy-3f3ed4743a3dda8901a35aa14d8e1c689933a1a4.tar.bz2 mitmproxy-3f3ed4743a3dda8901a35aa14d8e1c689933a1a4.zip |
Merge pull request #3371 from JessicaFavin/proper-display-on-stderr
Display errors on sys.stderr
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_dumper.py | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/test/mitmproxy/addons/test_dumper.py b/test/mitmproxy/addons/test_dumper.py index c24801e4..7a41c7b9 100644 --- a/test/mitmproxy/addons/test_dumper.py +++ b/test/mitmproxy/addons/test_dumper.py @@ -32,37 +32,50 @@ def test_configure(): def test_simple(): sio = io.StringIO() - d = dumper.Dumper(sio) + sio_err = io.StringIO() + d = dumper.Dumper(sio, sio_err) with taddons.context(d) as ctx: ctx.configure(d, flow_detail=0) d.response(tflow.tflow(resp=True)) assert not sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) ctx.configure(d, flow_detail=1) d.response(tflow.tflow(resp=True)) assert sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) ctx.configure(d, flow_detail=1) d.error(tflow.tflow(err=True)) assert sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) ctx.configure(d, flow_detail=4) d.response(tflow.tflow(resp=True)) assert sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) ctx.configure(d, flow_detail=4) d.response(tflow.tflow(resp=True)) assert "<<" in sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) ctx.configure(d, flow_detail=4) d.response(tflow.tflow(err=True)) assert "<<" in sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) ctx.configure(d, flow_detail=4) flow = tflow.tflow() @@ -75,6 +88,8 @@ def test_simple(): d.response(flow) assert sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) ctx.configure(d, flow_detail=4) flow = tflow.tflow(resp=tutils.tresp(content=b"{")) @@ -83,6 +98,8 @@ def test_simple(): d.response(flow) assert sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) ctx.configure(d, flow_detail=4) flow = tflow.tflow() @@ -92,6 +109,8 @@ def test_simple(): d.response(flow) assert "content missing" in sio.getvalue() sio.truncate(0) + assert not sio_err.getvalue() + sio_err.truncate(0) def test_echo_body(): @@ -100,7 +119,8 @@ def test_echo_body(): f.response.content = b"foo bar voing\n" * 100 sio = io.StringIO() - d = dumper.Dumper(sio) + sio_err = io.StringIO() + d = dumper.Dumper(sio, sio_err) with taddons.context(d) as ctx: ctx.configure(d, flow_detail=3) d._echo_message(f.response) @@ -110,7 +130,8 @@ def test_echo_body(): def test_echo_request_line(): sio = io.StringIO() - d = dumper.Dumper(sio) + sio_err = io.StringIO() + d = dumper.Dumper(sio, sio_err) with taddons.context(d) as ctx: ctx.configure(d, flow_detail=3, showhost=True) f = tflow.tflow(client_conn=None, server_conn=True, resp=True) @@ -146,7 +167,8 @@ class TestContentView: with mock.patch("mitmproxy.contentviews.auto.ViewAuto.__call__") as va: va.side_effect = exceptions.ContentViewException("") sio = io.StringIO() - d = dumper.Dumper(sio) + sio_err = io.StringIO() + d = dumper.Dumper(sio, sio_err) with taddons.context(d) as ctx: ctx.configure(d, flow_detail=4) d.response(tflow.tflow()) @@ -155,7 +177,8 @@ class TestContentView: def test_tcp(): sio = io.StringIO() - d = dumper.Dumper(sio) + sio_err = io.StringIO() + d = dumper.Dumper(sio, sio_err) with taddons.context(d) as ctx: ctx.configure(d, flow_detail=3, showhost=True) f = tflow.ttcpflow() @@ -165,12 +188,13 @@ def test_tcp(): f = tflow.ttcpflow(client_conn=True, err=True) d.tcp_error(f) - assert "Error in TCP" in sio.getvalue() + assert "Error in TCP" in sio_err.getvalue() def test_websocket(): sio = io.StringIO() - d = dumper.Dumper(sio) + sio_err = io.StringIO() + d = dumper.Dumper(sio, sio_err) with taddons.context(d) as ctx: ctx.configure(d, flow_detail=3, showhost=True) f = tflow.twebsocketflow() @@ -183,4 +207,4 @@ def test_websocket(): f = tflow.twebsocketflow(client_conn=True, err=True) d.websocket_error(f) - assert "Error in WebSocket" in sio.getvalue() + assert "Error in WebSocket" in sio_err.getvalue() |