aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_script.py11
-rw-r--r--test/mitmproxy/data/addonscripts/configure.py21
2 files changed, 32 insertions, 0 deletions
diff --git a/test/mitmproxy/addons/test_script.py b/test/mitmproxy/addons/test_script.py
index 05472d9a..61e19174 100644
--- a/test/mitmproxy/addons/test_script.py
+++ b/test/mitmproxy/addons/test_script.py
@@ -137,6 +137,17 @@ class TestScript:
assert await tctx.master.await_log("error.py")
@pytest.mark.asyncio
+ async def test_optionexceptions(self, tdata):
+ with taddons.context() as tctx:
+ sc = script.Script(
+ tdata.path("mitmproxy/data/addonscripts/configure.py"),
+ True,
+ )
+ tctx.master.addons.add(sc)
+ tctx.configure(sc)
+ assert await tctx.master.await_log("Options Error")
+
+ @pytest.mark.asyncio
async def test_addon(self, tdata):
with taddons.context() as tctx:
sc = script.Script(
diff --git a/test/mitmproxy/data/addonscripts/configure.py b/test/mitmproxy/data/addonscripts/configure.py
new file mode 100644
index 00000000..6f6ac06a
--- /dev/null
+++ b/test/mitmproxy/data/addonscripts/configure.py
@@ -0,0 +1,21 @@
+import typing
+
+from mitmproxy import exceptions
+
+
+class OptionAddon:
+ def load(self, loader):
+ loader.add_option(
+ name = "optionaddon",
+ typespec = typing.Optional[int],
+ default = None,
+ help = "Option Addon",
+ )
+
+ def configure(self, updates):
+ raise exceptions.OptionsError("Options Error")
+
+addons = [
+ OptionAddon()
+]
+