mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Merge pull request #2502 from mhils/optmanager
Fix optmanager equality check and deepcopy
This commit is contained in:
commit
6d9b5b0c06
@ -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