diff options
Diffstat (limited to 'test/tutils.py')
-rw-r--r-- | test/tutils.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/tutils.py b/test/tutils.py index 3f6592b0..c527a64a 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -1,4 +1,4 @@ -import os, shutil, tempfile +import os, shutil, tempfile, argparse from contextlib import contextmanager from libmproxy import flow, utils, controller from libmproxy.protocol import http @@ -136,6 +136,15 @@ def tmpdir(*args, **kwargs): shutil.rmtree(temp_workdir) +class MockParser(argparse.ArgumentParser): + """ + argparse.ArgumentParser sys.exits() by default. + Make it more testable by throwing an exception instead. + """ + def error(self, message): + raise Exception(message) + + def raises(exc, obj, *args, **kwargs): """ Assert that a callable raises a specified exception. |