aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-08-03 18:53:08 +0800
committerMatthew Shao <me@matshao.com>2017-08-03 18:57:54 +0800
commitb42f5bcb9dd6a8d2609b8351f846a654a1fd65c2 (patch)
tree66ef2cdf61337ef710555cb80d609f08db5bb89f
parentddffcf83ecef8b6c81e5f23ff57ae17af6131219 (diff)
downloadmitmproxy-b42f5bcb9dd6a8d2609b8351f846a654a1fd65c2.tar.gz
mitmproxy-b42f5bcb9dd6a8d2609b8351f846a654a1fd65c2.tar.bz2
mitmproxy-b42f5bcb9dd6a8d2609b8351f846a654a1fd65c2.zip
Update taddon and tests.
-rw-r--r--mitmproxy/addonmanager.py4
-rw-r--r--mitmproxy/test/taddons.py4
-rw-r--r--test/mitmproxy/addons/test_script.py6
-rw-r--r--test/mitmproxy/tools/console/test_statusbar.py3
4 files changed, 8 insertions, 9 deletions
diff --git a/mitmproxy/addonmanager.py b/mitmproxy/addonmanager.py
index 857ed530..31665548 100644
--- a/mitmproxy/addonmanager.py
+++ b/mitmproxy/addonmanager.py
@@ -202,6 +202,10 @@ class AddonManager:
def __str__(self):
return pprint.pformat([str(i) for i in self.chain])
+ def __contains__(self, item):
+ name = _get_name(item)
+ return name in self.lookup
+
def handle_lifecycle(self, name, message):
"""
Handle a lifecycle event.
diff --git a/mitmproxy/test/taddons.py b/mitmproxy/test/taddons.py
index 3859e4d2..d966f1d5 100644
--- a/mitmproxy/test/taddons.py
+++ b/mitmproxy/test/taddons.py
@@ -105,8 +105,8 @@ class context:
Options object with the given keyword arguments, then calls the
configure method on the addon with the updated value.
"""
- loader = addonmanager.Loader(self.master)
- self.master.addons.invoke_addon(addon, "load", loader)
+ if addon not in self.master.addons:
+ self.master.addons.register(addon)
with self.options.rollback(kwargs.keys(), reraise=True):
self.options.update(**kwargs)
self.master.addons.invoke_addon(
diff --git a/test/mitmproxy/addons/test_script.py b/test/mitmproxy/addons/test_script.py
index 5b05aec8..64fd9505 100644
--- a/test/mitmproxy/addons/test_script.py
+++ b/test/mitmproxy/addons/test_script.py
@@ -260,9 +260,6 @@ class TestScriptLoader:
debug = [i.msg for i in tctx.master.logs if i.level == "debug"]
assert debug == [
- 'a load',
- 'b load',
- 'c load',
'c configure',
'a configure',
'b configure',
@@ -280,9 +277,6 @@ class TestScriptLoader:
debug = [i.msg for i in tctx.master.logs if i.level == "debug"]
assert debug == [
- 'c load',
- 'a load',
- 'b load',
'c done',
'b done',
'a configure',
diff --git a/test/mitmproxy/tools/console/test_statusbar.py b/test/mitmproxy/tools/console/test_statusbar.py
index 34981e42..0cb36c45 100644
--- a/test/mitmproxy/tools/console/test_statusbar.py
+++ b/test/mitmproxy/tools/console/test_statusbar.py
@@ -1,5 +1,5 @@
from mitmproxy import options
-from mitmproxy.tools.console import statusbar, master
+from mitmproxy.tools.console import statusbar, master, consoleaddons
def test_statusbar(monkeypatch):
@@ -25,6 +25,7 @@ def test_statusbar(monkeypatch):
save_stream_file="foo",
)
m = master.ConsoleMaster(o)
+ m.options.update(view_order='url', console_focus_follow=True)
monkeypatch.setattr(m.addons.get("clientplayback"), "count", lambda: 42)
monkeypatch.setattr(m.addons.get("serverplayback"), "count", lambda: 42)