From a73ad1d945c9d3371c1530113a1c4ea3446f3fd4 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sat, 26 Jul 2014 11:51:27 +0200 Subject: fix tests --- examples/modify_response_body.py | 3 +-- test/test_examples.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/modify_response_body.py b/examples/modify_response_body.py index 3d485a7a..255d43f0 100644 --- a/examples/modify_response_body.py +++ b/examples/modify_response_body.py @@ -7,8 +7,7 @@ from libmproxy.protocol.http import decoded def start(ctx, argv): if len(argv) != 3: - ctx.log('Usage: -s "modify-response-body.py old new"') - sys.exit(1) + sys.exit('Usage: -s "modify-response-body.py old new"') global old, new # In larger scripts, a centralized options object (as returned by argparse) is encouraged old, new = argv[1:] diff --git a/test/test_examples.py b/test/test_examples.py index fa57b7eb..d18b5862 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -1,12 +1,17 @@ -from libmproxy import utils, script import glob +from libmproxy import utils, script from libmproxy.proxy import config import tservers -example_dir = utils.Data("libmproxy").path("../examples") -scripts = glob.glob("%s/*.py" % example_dir) -tmaster = tservers.TestMaster(config.ProxyConfig()) +def test_load_scripts(): + + example_dir = utils.Data("libmproxy").path("../examples") + scripts = glob.glob("%s/*.py" % example_dir) + + tmaster = tservers.TestMaster(config.ProxyConfig()) -for f in scripts: - script.Script(f, tmaster) # Loads the script file. \ No newline at end of file + for f in scripts: + if "modify_response_body" in f: + f += " foo bar" # two arguments required + script.Script(f, tmaster) # Loads the script file. \ No newline at end of file -- cgit v1.2.3