aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_script.py27
-rw-r--r--test/mitmproxy/data/addonscripts/load_error.py2
2 files changed, 23 insertions, 6 deletions
diff --git a/test/mitmproxy/addons/test_script.py b/test/mitmproxy/addons/test_script.py
index 64fd9505..aa7ca68e 100644
--- a/test/mitmproxy/addons/test_script.py
+++ b/test/mitmproxy/addons/test_script.py
@@ -1,15 +1,16 @@
-import traceback
-import sys
import os
+import sys
+import traceback
+from unittest import mock
+
import pytest
-from unittest import mock
-from mitmproxy.test import tflow
-from mitmproxy.test import tutils
-from mitmproxy.test import taddons
from mitmproxy import addonmanager
from mitmproxy import exceptions
from mitmproxy.addons import script
+from mitmproxy.test import taddons
+from mitmproxy.test import tflow
+from mitmproxy.test import tutils
def test_load_script():
@@ -216,6 +217,20 @@ class TestScriptLoader:
assert not tctx.options.scripts
assert not sl.addons
+ def test_load_err(self):
+ sc = script.ScriptLoader()
+ with taddons.context() as tctx:
+ tctx.configure(sc, scripts=[
+ tutils.test_data.path("mitmproxy/data/addonscripts/load_error.py")
+ ])
+ try:
+ tctx.invoke(sc, "tick")
+ except ValueError:
+ pass # this is expected and normally guarded.
+ # on the next tick we should not fail however.
+ tctx.invoke(sc, "tick")
+ assert len(tctx.master.addons) == 0
+
def test_order(self):
rec = tutils.test_data.path("mitmproxy/data/addonscripts/recorder")
sc = script.ScriptLoader()
diff --git a/test/mitmproxy/data/addonscripts/load_error.py b/test/mitmproxy/data/addonscripts/load_error.py
new file mode 100644
index 00000000..4c05e9ed
--- /dev/null
+++ b/test/mitmproxy/data/addonscripts/load_error.py
@@ -0,0 +1,2 @@
+def load(_):
+ raise ValueError()