mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Re-add state operations to ODict.
This commit is contained in:
parent
e381c03668
commit
1acaf1c880
@ -96,6 +96,16 @@ class ODict:
|
||||
def items(self):
|
||||
return self.lst[:]
|
||||
|
||||
def _get_state(self):
|
||||
return [tuple(i) for i in self.lst]
|
||||
|
||||
def _load_state(self, state):
|
||||
self.list = [list(i) for i in state]
|
||||
|
||||
@classmethod
|
||||
def _from_state(klass, state):
|
||||
return klass([list(i) for i in state])
|
||||
|
||||
def copy(self):
|
||||
"""
|
||||
Returns a copy of this object.
|
||||
|
@ -24,6 +24,15 @@ class TestODict:
|
||||
for i in expected:
|
||||
assert out.find(i) >= 0
|
||||
|
||||
def test_getset_state(self):
|
||||
self.od.add("foo", 1)
|
||||
self.od.add("foo", 2)
|
||||
self.od.add("bar", 3)
|
||||
state = self.od._get_state()
|
||||
nd = odict.ODict._from_state(state)
|
||||
assert nd == self.od
|
||||
nd._load_state(state)
|
||||
|
||||
def test_dictToHeader2(self):
|
||||
self.od["one"] = ["uno"]
|
||||
expected1 = "one: uno\r\n"
|
||||
|
Loading…
Reference in New Issue
Block a user