diff --git a/mitmproxy/test/taddons.py b/mitmproxy/test/taddons.py index 6160746a0..3859e4d29 100644 --- a/mitmproxy/test/taddons.py +++ b/mitmproxy/test/taddons.py @@ -105,6 +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) 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 64fd95058..5b05aec81 100644 --- a/test/mitmproxy/addons/test_script.py +++ b/test/mitmproxy/addons/test_script.py @@ -260,6 +260,9 @@ 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', @@ -277,6 +280,9 @@ 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/addons/test_view.py b/test/mitmproxy/addons/test_view.py index 9a9534f98..a2e45e9be 100644 --- a/test/mitmproxy/addons/test_view.py +++ b/test/mitmproxy/addons/test_view.py @@ -7,10 +7,7 @@ from mitmproxy import flowfilter from mitmproxy import exceptions from mitmproxy import io from mitmproxy.test import taddons -from mitmproxy import options -from mitmproxy.tools.console.master import ConsoleMaster - -m = ConsoleMaster(options.Options()) +from mitmproxy.tools.console import consoleaddons def tft(*, method="get", start=0): @@ -30,8 +27,8 @@ def test_order_refresh(): v.sig_view_refresh.connect(save) tf = tflow.tflow(resp=True) - with taddons.context(m) as tctx: - tctx.configure(v, console_order="time") + with taddons.context() as tctx: + tctx.configure(v, view_order="time") v.add([tf]) tf.request.timestamp_start = 1 assert not sargs @@ -297,19 +294,19 @@ def test_setgetval(): def test_order(): v = view.View() - with taddons.context(m) as tctx: + with taddons.context() as tctx: v.request(tft(method="get", start=1)) v.request(tft(method="put", start=2)) v.request(tft(method="get", start=3)) v.request(tft(method="put", start=4)) assert [i.request.timestamp_start for i in v] == [1, 2, 3, 4] - tctx.configure(v, console_order="method") + tctx.configure(v, view_order="method") assert [i.request.method for i in v] == ["GET", "GET", "PUT", "PUT"] v.set_reversed(True) assert [i.request.method for i in v] == ["PUT", "PUT", "GET", "GET"] - tctx.configure(v, console_order="time") + tctx.configure(v, view_order="time") assert [i.request.timestamp_start for i in v] == [4, 3, 2, 1] v.set_reversed(False) @@ -428,7 +425,9 @@ def test_signals(): def test_focus_follow(): v = view.View() - with taddons.context(m) as tctx: + with taddons.context() as tctx: + console_addon = consoleaddons.ConsoleAddon(tctx.master) + tctx.configure(console_addon) tctx.configure(v, console_focus_follow=True, view_filter="~m get") v.add([tft(start=5)]) @@ -545,16 +544,18 @@ def test_settings(): def test_configure(): v = view.View() - with taddons.context(m) as tctx: + with taddons.context() as tctx: tctx.configure(v, view_filter="~q") with pytest.raises(Exception, match="Invalid interception filter"): tctx.configure(v, view_filter="~~") - tctx.configure(v, console_order="method") + tctx.configure(v, view_order="method") with pytest.raises(Exception, match="Unknown flow order"): - tctx.configure(v, console_order="no") + tctx.configure(v, view_order="no") - tctx.configure(v, console_order_reversed=True) + tctx.configure(v, view_order_reversed=True) + console_addon = consoleaddons.ConsoleAddon(tctx.master) + tctx.configure(console_addon) tctx.configure(v, console_focus_follow=True) assert v.focus_follow