diff options
author | Maximilian Hils <git@maximilianhils.com> | 2013-06-16 00:41:43 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2013-06-16 00:41:43 +0200 |
commit | fd36142018a18f0d6c996e9c07bfc7e80e20afc4 (patch) | |
tree | 6a42399d1150a6196c71c7fb7bd80b0dc6fbf58b /test/test_script.py | |
parent | 34f286df511d0d6987a21e105a7cde651130fa2d (diff) | |
parent | b4f6f09c83faf54c4c1493e18ba11d0257ca841b (diff) | |
download | mitmproxy-fd36142018a18f0d6c996e9c07bfc7e80e20afc4.tar.gz mitmproxy-fd36142018a18f0d6c996e9c07bfc7e80e20afc4.tar.bz2 mitmproxy-fd36142018a18f0d6c996e9c07bfc7e80e20afc4.zip |
Merge remote-tracking branch 'origin/scripts_improvements' into 0.10
Diffstat (limited to 'test/test_script.py')
-rw-r--r-- | test/test_script.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/test/test_script.py b/test/test_script.py index 407c9b4b..9033c4fc 100644 --- a/test/test_script.py +++ b/test/test_script.py @@ -1,5 +1,7 @@ from libmproxy import script, flow import tutils +import shlex +import os class TestScript: def test_simple(self): @@ -7,11 +9,12 @@ class TestScript: fm = flow.FlowMaster(None, s) ctx = flow.ScriptContext(fm) - p = script.Script(tutils.test_data.path("scripts/a.py"), ctx) + p = script.Script(shlex.split(tutils.test_data.path("scripts/a.py")+" --var 40", posix=(os.name != "nt")), ctx) p.load() + assert "here" in p.ns - assert p.run("here") == (True, 1) - assert p.run("here") == (True, 2) + assert p.run("here") == (True, 41) + assert p.run("here") == (True, 42) ret = p.run("errargs") assert not ret[0] @@ -19,12 +22,12 @@ class TestScript: # Check reload p.load() - assert p.run("here") == (True, 1) + assert p.run("here") == (True, 41) def test_duplicate_flow(self): s = flow.State() fm = flow.FlowMaster(None, s) - fm.load_script(tutils.test_data.path("scripts/duplicate_flow.py")) + fm.load_script([tutils.test_data.path("scripts/duplicate_flow.py")]) r = tutils.treq() fm.handle_request(r) assert fm.state.flow_count() == 2 @@ -37,25 +40,25 @@ class TestScript: ctx = flow.ScriptContext(fm) - s = script.Script("nonexistent", ctx) + s = script.Script(["nonexistent"], ctx) tutils.raises( "no such file", s.load ) - s = script.Script(tutils.test_data.path("scripts"), ctx) + s = script.Script([tutils.test_data.path("scripts")], ctx) tutils.raises( "not a file", s.load ) - s = script.Script(tutils.test_data.path("scripts/syntaxerr.py"), ctx) + s = script.Script([tutils.test_data.path("scripts/syntaxerr.py")], ctx) tutils.raises( script.ScriptError, s.load ) - s = script.Script(tutils.test_data.path("scripts/loaderr.py"), ctx) + s = script.Script([tutils.test_data.path("scripts/loaderr.py")], ctx) tutils.raises( script.ScriptError, s.load |