diff options
Diffstat (limited to 'test/mitmproxy/addons/test_streambodies.py')
-rw-r--r-- | test/mitmproxy/addons/test_streambodies.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/test/mitmproxy/addons/test_streambodies.py b/test/mitmproxy/addons/test_streambodies.py index afd2cc51..b982c66d 100644 --- a/test/mitmproxy/addons/test_streambodies.py +++ b/test/mitmproxy/addons/test_streambodies.py @@ -1,30 +1,28 @@ from mitmproxy.test import tflow - -from .. import mastertest -from mitmproxy import master -from mitmproxy import options -from mitmproxy import proxy +from mitmproxy.test import taddons from mitmproxy.addons import streambodies -class TestStreamBodies(mastertest.MasterTest): - def test_simple(self): - o = options.Options(stream_large_bodies = 10) - m = master.Master(o, proxy.DummyServer()) - sa = streambodies.StreamBodies() - m.addons.add(sa) +def test_simple(): + sa = streambodies.StreamBodies() + with taddons.context() as tctx: + tctx.configure(sa, stream_large_bodies = 10) f = tflow.tflow() f.request.content = b"" f.request.headers["Content-Length"] = "1024" assert not f.request.stream - m.requestheaders(f) + sa.requestheaders(f) assert f.request.stream f = tflow.tflow(resp=True) f.response.content = b"" f.response.headers["Content-Length"] = "1024" assert not f.response.stream - m.responseheaders(f) + sa.responseheaders(f) assert f.response.stream + + f = tflow.tflow(resp=True) + f.response.headers["content-length"] = "invalid" + tctx.cycle(sa, f) |