aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-12-02 16:15:14 +1300
committerAldo Cortesi <aldo@nullcube.com>2016-12-08 10:21:05 +1300
commitb4d33aaebf5fa78736b5d5f6864f672ccd08e716 (patch)
tree77398b5bebf787a8909ae0551f8ab5b10a2c8dda /test
parent4771abf2291947d580858c7fe58e25dbf0850abd (diff)
downloadmitmproxy-b4d33aaebf5fa78736b5d5f6864f672ccd08e716.tar.gz
mitmproxy-b4d33aaebf5fa78736b5d5f6864f672ccd08e716.tar.bz2
mitmproxy-b4d33aaebf5fa78736b5d5f6864f672ccd08e716.zip
options: save defaults, add .reset() to restore defaults
Use .reset() in console app to clear options.
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_optmanager.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py
index 3c845707..47e40d98 100644
--- a/test/mitmproxy/test_optmanager.py
+++ b/test/mitmproxy/test_optmanager.py
@@ -12,6 +12,43 @@ class TO(optmanager.OptManager):
super().__init__()
+class TD(optmanager.OptManager):
+ def __init__(self, one="done", two="dtwo", three="error"):
+ self.one = one
+ self.two = two
+ self.three = three
+ super().__init__()
+
+
+class TD2(TD):
+ def __init__(self, *, three="dthree", four="dfour", **kwargs):
+ self.three = three
+ self.four = four
+ super().__init__(**kwargs)
+
+
+def test_defaults():
+ o = TD2()
+ assert o._defaults == {
+ "one": "done",
+ "two": "dtwo",
+ "three": "dthree",
+ "four": "dfour",
+ }
+ newvals = dict(
+ one="xone",
+ two="xtwo",
+ three="xthree",
+ four="xfour",
+ )
+ o.update(**newvals)
+ for k, v in newvals.items():
+ assert v == o.get(k)
+ o.reset()
+ for k, v in o._defaults.items():
+ assert v == o.get(k)
+
+
def test_options():
o = TO(two="three")
assert o.keys() == set(["one", "two"])