From 24751965f99daf83c82d9c1581f712ca24da9d3d Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Wed, 21 Dec 2016 23:22:14 +0100 Subject: [PATCH] remove output of dumper during tests --- mitmproxy/tools/dump.py | 8 +++++--- mitmproxy/tools/web/master.py | 5 +++-- test/mitmproxy/test_tools_dump.py | 3 ++- test/mitmproxy/test_web_app.py | 3 +-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mitmproxy/tools/dump.py b/mitmproxy/tools/dump.py index 903326274..4e2844a1f 100644 --- a/mitmproxy/tools/dump.py +++ b/mitmproxy/tools/dump.py @@ -30,12 +30,14 @@ class Options(options.Options): class DumpMaster(master.Master): - def __init__(self, options, server): + def __init__(self, options, server, with_termlog=True, with_dumper=True): master.Master.__init__(self, options, server) self.has_errored = False - self.addons.add(termlog.TermLog()) + if with_termlog: + self.addons.add(termlog.TermLog()) self.addons.add(*addons.default_addons()) - self.addons.add(dumper.Dumper()) + if with_dumper: + self.addons.add(dumper.Dumper()) # This line is just for type hinting self.options = self.options # type: Options diff --git a/mitmproxy/tools/web/master.py b/mitmproxy/tools/web/master.py index 68a3db706..e6c15a0a4 100644 --- a/mitmproxy/tools/web/master.py +++ b/mitmproxy/tools/web/master.py @@ -15,7 +15,7 @@ from mitmproxy.tools.web import app class WebMaster(master.Master): - def __init__(self, options, server): + def __init__(self, options, server, with_termlog=True): super().__init__(options, server) self.view = view.View() self.view.sig_view_add.connect(self._sig_view_add) @@ -34,8 +34,9 @@ class WebMaster(master.Master): intercept.Intercept(), self.view, self.events, - termlog.TermLog(), ) + if with_termlog: + self.addons.add(termlog.TermLog()) self.app = app.Application( self, self.options.wdebug ) diff --git a/test/mitmproxy/test_tools_dump.py b/test/mitmproxy/test_tools_dump.py index 1488f33b6..2e64d2d2b 100644 --- a/test/mitmproxy/test_tools_dump.py +++ b/test/mitmproxy/test_tools_dump.py @@ -11,7 +11,8 @@ from . import mastertest class TestDumpMaster(mastertest.MasterTest): def mkmaster(self, flt, **options): o = dump.Options(filtstr=flt, verbosity=-1, flow_detail=0, **options) - return dump.DumpMaster(o, proxy.DummyServer()) + m = dump.DumpMaster(o, proxy.DummyServer(), with_termlog=False, with_dumper=False) + return m def test_read(self): with tutils.tmpdir() as t: diff --git a/test/mitmproxy/test_web_app.py b/test/mitmproxy/test_web_app.py index 8c15968bd..61cf69937 100644 --- a/test/mitmproxy/test_web_app.py +++ b/test/mitmproxy/test_web_app.py @@ -19,8 +19,7 @@ def json(resp: httpclient.HTTPResponse): class TestApp(tornado.testing.AsyncHTTPTestCase): def get_app(self): o = options.Options() - m = webmaster.WebMaster(o, proxy.DummyServer()) - m.addons.remove(m.addons.get('termlog')) + m = webmaster.WebMaster(o, proxy.DummyServer(), with_termlog=False) f = tflow.tflow(resp=True) f.id = "42" m.view.add(f)