aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-03-11 18:40:51 +0530
committerShadab Zafar <dufferzafar0@gmail.com>2016-03-11 18:40:51 +0530
commit5a1c3c4ad818df9355bb71326bc810e4ce361cb6 (patch)
treef5d7cd40cb173da742cc9b020beaf463169469ce
parent35204ecb1cb6221e0baee8b81e2165a0458fae60 (diff)
downloadmitmproxy-5a1c3c4ad818df9355bb71326bc810e4ce361cb6.tar.gz
mitmproxy-5a1c3c4ad818df9355bb71326bc810e4ce361cb6.tar.bz2
mitmproxy-5a1c3c4ad818df9355bb71326bc810e4ce361cb6.zip
Update contentview test
-rw-r--r--test/mitmproxy/test_examples.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py
index 2f29f9dd..803776ac 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("<html>test!</html>")
assert any('esttay!' in val[0][1] for val in fmt)
assert not pig("gobbledygook")