diff options
author | lymanZerga11 <lymanZerga11@users.noreply.github.com> | 2017-02-01 22:27:10 +0800 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-02-01 15:27:10 +0100 |
commit | 4b10212cafb526bdfbbc7c1e26cb5cbd505a0a8e (patch) | |
tree | 7f7e6835c83996da6074367c479e0a2b894d1b39 /test | |
parent | 212d9f1b9848fe347ef5924c2e7431180c550cb6 (diff) | |
download | mitmproxy-4b10212cafb526bdfbbc7c1e26cb5cbd505a0a8e.tar.gz mitmproxy-4b10212cafb526bdfbbc7c1e26cb5cbd505a0a8e.tar.bz2 mitmproxy-4b10212cafb526bdfbbc7c1e26cb5cbd505a0a8e.zip |
Add except clause to catch script parsing errors (#1929)
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_script.py | 5 | ||||
-rw-r--r-- | test/mitmproxy/console/test_master.py | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/test/mitmproxy/addons/test_script.py b/test/mitmproxy/addons/test_script.py index f6fca23e..6e04d49d 100644 --- a/test/mitmproxy/addons/test_script.py +++ b/test/mitmproxy/addons/test_script.py @@ -58,10 +58,10 @@ def test_reloadhandler(): class TestParseCommand: def test_empty_command(self): - with tutils.raises(exceptions.OptionsError): + with tutils.raises(ValueError): script.parse_command("") - with tutils.raises(exceptions.OptionsError): + with tutils.raises(ValueError): script.parse_command(" ") def test_no_script_file(self): @@ -203,6 +203,7 @@ class TestScriptLoader: evts = [i[1] for i in sc.ns.call_log] assert evts == ['start', 'requestheaders', 'request', 'responseheaders', 'response', 'done'] + f = tflow.tflow(resp=True) with m.handlecontext(): tutils.raises( "file not found", diff --git a/test/mitmproxy/console/test_master.py b/test/mitmproxy/console/test_master.py index fb3c2527..82cc6f9d 100644 --- a/test/mitmproxy/console/test_master.py +++ b/test/mitmproxy/console/test_master.py @@ -4,7 +4,6 @@ from mitmproxy.tools import console from mitmproxy import proxy from mitmproxy import options from mitmproxy.tools.console import common - from .. import mastertest @@ -27,7 +26,7 @@ def test_options(): class TestMaster(mastertest.MasterTest): def mkmaster(self, **opts): if "verbosity" not in opts: - opts["verbosity"] = 0 + opts["verbosity"] = 1 o = options.Options(**opts) return console.master.ConsoleMaster(o, proxy.DummyServer()) @@ -37,6 +36,12 @@ class TestMaster(mastertest.MasterTest): self.dummy_cycle(m, 1, b"") assert len(m.view) == i + def test_run_script_once(self): + m = self.mkmaster() + f = tflow.tflow(resp=True) + m.run_script_once("nonexistent", [f]) + assert "Input error" in str(m.logbuffer[0]) + def test_intercept(self): """regression test for https://github.com/mitmproxy/mitmproxy/issues/1605""" m = self.mkmaster(intercept="~b bar") |