diff options
Diffstat (limited to 'test/mitmproxy/mastertest.py')
-rw-r--r-- | test/mitmproxy/mastertest.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/test/mitmproxy/mastertest.py b/test/mitmproxy/mastertest.py index 08659d19..a14fe02a 100644 --- a/test/mitmproxy/mastertest.py +++ b/test/mitmproxy/mastertest.py @@ -1,8 +1,14 @@ +import contextlib + from . import tutils import netlib.tutils from mitmproxy.flow import master -from mitmproxy import flow, proxy, models, controller +from mitmproxy import flow, proxy, models, controller, options + + +class TestMaster: + pass class MasterTest: @@ -16,7 +22,9 @@ class MasterTest: master.serverconnect(f.server_conn) master.request(f) if not f.error: - f.response = models.HTTPResponse.wrap(netlib.tutils.tresp(content=content)) + f.response = models.HTTPResponse.wrap( + netlib.tutils.tresp(content=content) + ) master.response(f) master.clientdisconnect(f) return f @@ -41,3 +49,12 @@ class RecordingMaster(master.FlowMaster): def add_log(self, e, level): self.event_log.append((level, e)) + + +@contextlib.contextmanager +def mockctx(): + state = flow.State() + o = options.Options(refresh_server_playback = True, keepserving=False) + m = RecordingMaster(o, proxy.DummyServer(o), state) + with m.handlecontext(): + yield |