diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-11-02 08:51:26 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-11-02 08:51:26 +1300 |
commit | fc7606bd989145ce6c24e4120bfedfeb1a7bf746 (patch) | |
tree | d48aa6c343ff5b7610c629ad2eaa5f77e9ce1eb8 /test/mitmproxy/test_proxy.py | |
parent | ba09b8bff34869c3355e955d43e8e58e349a15ad (diff) | |
download | mitmproxy-fc7606bd989145ce6c24e4120bfedfeb1a7bf746.tar.gz mitmproxy-fc7606bd989145ce6c24e4120bfedfeb1a7bf746.tar.bz2 mitmproxy-fc7606bd989145ce6c24e4120bfedfeb1a7bf746.zip |
tests: minor cleanup for tests/mitmproxy/tutils.py
Diffstat (limited to 'test/mitmproxy/test_proxy.py')
-rw-r--r-- | test/mitmproxy/test_proxy.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/mitmproxy/test_proxy.py b/test/mitmproxy/test_proxy.py index 4ac6c177..ab210e65 100644 --- a/test/mitmproxy/test_proxy.py +++ b/test/mitmproxy/test_proxy.py @@ -1,6 +1,7 @@ from mitmproxy.test import tflow import os import mock +import argparse from OpenSSL import SSL from mitmproxy.tools import cmdline @@ -55,10 +56,21 @@ class TestServerConnection: assert "foo" in repr(sc) +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) + + class TestProcessProxyOptions: def p(self, *args): - parser = tutils.MockParser() + parser = MockParser() cmdline.common_options(parser) args = parser.parse_args(args=args) opts = cmdline.get_common_options(args) |