diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index 08d155cf4..01d97af31 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -150,13 +150,17 @@ class OptManager: self.changed.connect(_call, weak=False) def __eq__(self, other): - return self._options == other._options + if isinstance(other, OptManager): + return self._options == other._options + return False - def __copy__(self): + def __deepcopy__(self, memodict = None): o = OptManager() - o.__dict__["_options"] = copy.deepcopy(self._options) + o.__dict__["_options"] = copy.deepcopy(self._options, memodict) return o + __copy__ = __deepcopy__ + def __getattr__(self, attr): if attr in self._options: return self._options[attr].current() diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py index fe72e6bb8..d9b932277 100644 --- a/test/mitmproxy/test_optmanager.py +++ b/test/mitmproxy/test_optmanager.py @@ -73,6 +73,11 @@ def test_required_int(): o.parse_setval("required_int", None) +def test_deepcopy(): + o = TD() + copy.deepcopy(o) + + def test_options(): o = TO() assert o.keys() == {"bool", "one", "two", "required_int"} @@ -244,6 +249,7 @@ def test_serialize(): o2 = TD2() optmanager.load(o2, data) assert o2 == o + assert not o == 42 t = """ unknown: foo