mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
fix optmanager equality check and deepcopy
This commit is contained in:
parent
819a85df74
commit
e30750bf9e
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user