diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2016-12-03 09:42:14 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2016-12-08 10:21:06 +1300 |
commit | 0c091bd92b9f0f59c65cf392f334719294ef397e (patch) | |
tree | 353dfb281e24cdb15af483f44cc0e97184b2d139 /test | |
parent | b231836c70a68daa6016537e5ec18ed7a7cc3b1a (diff) | |
download | mitmproxy-0c091bd92b9f0f59c65cf392f334719294ef397e.tar.gz mitmproxy-0c091bd92b9f0f59c65cf392f334719294ef397e.tar.bz2 mitmproxy-0c091bd92b9f0f59c65cf392f334719294ef397e.zip |
Options - avoid mutation, API cleanup, has_changed
- Always return a deepcopy of options to avoid accidental mutation of options
state.
- Remove .get(opt, default). This is an inappropriate API for Options - trying
to retrieve an option that doesn't exist should always be an error.
- Add the has_changed method that checks if an option differs from the default,
use it in mitmproxy console.
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/test_optmanager.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py index 47e40d98..345512fd 100644 --- a/test/mitmproxy/test_optmanager.py +++ b/test/mitmproxy/test_optmanager.py @@ -35,6 +35,7 @@ def test_defaults(): "three": "dthree", "four": "dfour", } + assert not o.has_changed("one") newvals = dict( one="xone", two="xtwo", @@ -42,11 +43,13 @@ def test_defaults(): four="xfour", ) o.update(**newvals) + assert o.has_changed("one") for k, v in newvals.items(): - assert v == o.get(k) + assert v == getattr(o, k) o.reset() + assert not o.has_changed("one") for k, v in o._defaults.items(): - assert v == o.get(k) + assert v == getattr(o, k) def test_options(): |