Adjust for state object protocol changes in mitmproxy.
This commit is contained in:
parent
b21df0cf44
commit
414a0a1602
|
@ -101,16 +101,6 @@ class ODict:
|
||||||
def items(self):
|
def items(self):
|
||||||
return self.lst[:]
|
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):
|
def copy(self):
|
||||||
"""
|
"""
|
||||||
Returns a copy of this object.
|
Returns a copy of this object.
|
||||||
|
@ -171,6 +161,18 @@ class ODict:
|
||||||
self.lst = nlst
|
self.lst = nlst
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
# Implement the StateObject protocol from mitmproxy
|
||||||
|
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])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ODictCaseless(ODict):
|
class ODictCaseless(ODict):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -28,10 +28,10 @@ class TestODict:
|
||||||
self.od.add("foo", 1)
|
self.od.add("foo", 1)
|
||||||
self.od.add("foo", 2)
|
self.od.add("foo", 2)
|
||||||
self.od.add("bar", 3)
|
self.od.add("bar", 3)
|
||||||
state = self.od._get_state()
|
state = self.od.get_state()
|
||||||
nd = odict.ODict._from_state(state)
|
nd = odict.ODict.from_state(state)
|
||||||
assert nd == self.od
|
assert nd == self.od
|
||||||
nd._load_state(state)
|
nd.load_state(state)
|
||||||
|
|
||||||
def test_dictToHeader2(self):
|
def test_dictToHeader2(self):
|
||||||
self.od["one"] = ["uno"]
|
self.od["one"] = ["uno"]
|
||||||
|
|
Loading…
Reference in New Issue