diff options
author | Aldo Cortesi <aldo@corte.si> | 2018-04-06 10:01:35 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-06 10:01:35 +1200 |
commit | 4177f50a0fe177eb15e1adaf1d7941f3ae1dbdbc (patch) | |
tree | 7488eb81e62d2666d0bb7347219516520391a99a /test | |
parent | 48426d0a20b122b2b309c4fb7c61c412ff980f0d (diff) | |
parent | 22b514977761c84dfc9eed1c0c3363f977b273d6 (diff) | |
download | mitmproxy-4177f50a0fe177eb15e1adaf1d7941f3ae1dbdbc.tar.gz mitmproxy-4177f50a0fe177eb15e1adaf1d7941f3ae1dbdbc.tar.bz2 mitmproxy-4177f50a0fe177eb15e1adaf1d7941f3ae1dbdbc.zip |
Merge pull request #2971 from kira0204/user-script-exception
A unified handler for user's scripts exception
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_script.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/test/mitmproxy/addons/test_script.py b/test/mitmproxy/addons/test_script.py index dc21e6fd..79fa22dc 100644 --- a/test/mitmproxy/addons/test_script.py +++ b/test/mitmproxy/addons/test_script.py @@ -183,9 +183,9 @@ class TestScriptLoader: def test_script_run_nonexistent(self): sc = script.ScriptLoader() - with taddons.context(sc): - with pytest.raises(exceptions.CommandError): - sc.script_run([tflow.tflow(resp=True)], "/") + with taddons.context(sc) as tctx: + sc.script_run([tflow.tflow(resp=True)], "/") + tctx.master.has_log("/: No such script") def test_simple(self): sc = script.ScriptLoader() @@ -243,6 +243,18 @@ class TestScriptLoader: tctx.invoke(sc, "tick") assert len(tctx.master.addons) == 1 + def test_script_error_handler(self): + path = "/sample/path/example.py" + exc = SyntaxError + msg = "Error raised" + tb = True + with taddons.context() as tctx: + script.script_error_handler(path, exc, msg, tb) + assert tctx.master.has_log("/sample/path/example.py") + assert tctx.master.has_log("Error raised") + assert tctx.master.has_log("lineno") + assert tctx.master.has_log("NoneType") + def test_order(self): rec = tutils.test_data.path("mitmproxy/data/addonscripts/recorder") sc = script.ScriptLoader() |