aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Kriechbaumer <Kriechi@users.noreply.github.com>2017-02-25 12:12:43 +0100
committerGitHub <noreply@github.com>2017-02-25 12:12:43 +0100
commit2aecffd39abb41c500573d823f0a05b1f7522041 (patch)
treebcdeb35cb352a721f38f8e5e4abfd4da6e988dc2
parentccd8e1e617cdbf3b34ec01ac130093396197101f (diff)
downloadmitmproxy-2aecffd39abb41c500573d823f0a05b1f7522041.tar.gz
mitmproxy-2aecffd39abb41c500573d823f0a05b1f7522041.tar.bz2
mitmproxy-2aecffd39abb41c500573d823f0a05b1f7522041.zip
optmanager: coverage++ (#2062)
-rw-r--r--setup.cfg2
-rw-r--r--test/mitmproxy/test_optmanager.py22
2 files changed, 15 insertions, 9 deletions
diff --git a/setup.cfg b/setup.cfg
index 634b7a95..1825f434 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -41,7 +41,6 @@ exclude =
mitmproxy/flow.py
mitmproxy/io_compat.py
mitmproxy/master.py
- mitmproxy/optmanager.py
pathod/pathoc.py
pathod/pathod.py
pathod/test.py
@@ -74,7 +73,6 @@ exclude =
mitmproxy/net/http/url.py
mitmproxy/net/tcp.py
mitmproxy/options.py
- mitmproxy/optmanager.py
mitmproxy/proxy/config.py
mitmproxy/proxy/modes/http_proxy.py
mitmproxy/proxy/modes/reverse_proxy.py
diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py
index 65691fdf..161b0dcf 100644
--- a/test/mitmproxy/test_optmanager.py
+++ b/test/mitmproxy/test_optmanager.py
@@ -30,6 +30,14 @@ class TD2(TD):
super().__init__(three=three, **kwargs)
+class TM(optmanager.OptManager):
+ def __init__(self, one="one", two=["foo"], three=None):
+ self.one = one
+ self.two = two
+ self.three = three
+ super().__init__()
+
+
def test_defaults():
assert TD2.default("one") == "done"
assert TD2.default("two") == "dtwo"
@@ -203,6 +211,9 @@ def test_serialize():
t = ""
o2.load(t)
+ with pytest.raises(exceptions.OptionsError, matches='No such option: foobar'):
+ o2.load("foobar: '123'")
+
def test_serialize_defaults():
o = options.Options()
@@ -224,13 +235,10 @@ def test_saving():
o.load_paths(dst)
assert o.three == "foo"
-
-class TM(optmanager.OptManager):
- def __init__(self, one="one", two=["foo"], three=None):
- self.one = one
- self.two = two
- self.three = three
- super().__init__()
+ with open(dst, 'a') as f:
+ f.write("foobar: '123'")
+ with pytest.raises(exceptions.OptionsError, matches=''):
+ o.load_paths(dst)
def test_merge():