optmanager: coverage++ (#2062)

This commit is contained in:
Thomas Kriechbaumer 2017-02-25 12:12:43 +01:00 committed by GitHub
parent ccd8e1e617
commit 2aecffd39a
2 changed files with 15 additions and 9 deletions

View File

@ -41,7 +41,6 @@ exclude =
mitmproxy/flow.py mitmproxy/flow.py
mitmproxy/io_compat.py mitmproxy/io_compat.py
mitmproxy/master.py mitmproxy/master.py
mitmproxy/optmanager.py
pathod/pathoc.py pathod/pathoc.py
pathod/pathod.py pathod/pathod.py
pathod/test.py pathod/test.py
@ -74,7 +73,6 @@ exclude =
mitmproxy/net/http/url.py mitmproxy/net/http/url.py
mitmproxy/net/tcp.py mitmproxy/net/tcp.py
mitmproxy/options.py mitmproxy/options.py
mitmproxy/optmanager.py
mitmproxy/proxy/config.py mitmproxy/proxy/config.py
mitmproxy/proxy/modes/http_proxy.py mitmproxy/proxy/modes/http_proxy.py
mitmproxy/proxy/modes/reverse_proxy.py mitmproxy/proxy/modes/reverse_proxy.py

View File

@ -30,6 +30,14 @@ class TD2(TD):
super().__init__(three=three, **kwargs) 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(): def test_defaults():
assert TD2.default("one") == "done" assert TD2.default("one") == "done"
assert TD2.default("two") == "dtwo" assert TD2.default("two") == "dtwo"
@ -203,6 +211,9 @@ def test_serialize():
t = "" t = ""
o2.load(t) o2.load(t)
with pytest.raises(exceptions.OptionsError, matches='No such option: foobar'):
o2.load("foobar: '123'")
def test_serialize_defaults(): def test_serialize_defaults():
o = options.Options() o = options.Options()
@ -224,13 +235,10 @@ def test_saving():
o.load_paths(dst) o.load_paths(dst)
assert o.three == "foo" assert o.three == "foo"
with open(dst, 'a') as f:
class TM(optmanager.OptManager): f.write("foobar: '123'")
def __init__(self, one="one", two=["foo"], three=None): with pytest.raises(exceptions.OptionsError, matches=''):
self.one = one o.load_paths(dst)
self.two = two
self.three = three
super().__init__()
def test_merge(): def test_merge():