From 5a1c3c4ad818df9355bb71326bc810e4ce361cb6 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Fri, 11 Mar 2016 18:40:51 +0530 Subject: [PATCH] Update contentview test --- test/mitmproxy/test_examples.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py index 2f29f9dd3..803776ac8 100644 --- a/test/mitmproxy/test_examples.py +++ b/test/mitmproxy/test_examples.py @@ -3,7 +3,7 @@ import json import os from contextlib import contextmanager -from mitmproxy import utils, script, contentviews +from mitmproxy import utils, script from mitmproxy.proxy import config from netlib import tutils as netutils from netlib.http import Headers @@ -15,11 +15,16 @@ example_dir = utils.Data(__name__).path("../../examples") class DummyContext(object): """Emulate script.ScriptContext() functionality.""" + contentview = None + def log(self, *args, **kwargs): pass def add_contentview(self, view_obj): - pass + self.contentview = view_obj + + def remove_contentview(self, view_obj): + self.contentview = None @contextmanager @@ -64,8 +69,8 @@ def test_add_header(): def test_custom_contentviews(): - with example("custom_contentviews.py"): - pig = contentviews.get_by_shortcut("l") + with example("custom_contentviews.py") as ex: + pig = ex.ctx.contentview _, fmt = pig("test!") assert any('esttay!' in val[0][1] for val in fmt) assert not pig("gobbledygook")