fix revert of duplicated flows

This commit is contained in:
Maximilian Hils 2017-11-06 15:24:54 +01:00
parent 4cb96dedd0
commit e6e28c2ac3
3 changed files with 13 additions and 0 deletions

View File

@ -99,6 +99,7 @@ class Flow(stateobject.StateObject):
return d
def set_state(self, state):
state = state.copy()
state.pop("version")
if "backup" in state:
self._backup = state.pop("backup")

View File

@ -56,6 +56,7 @@ class HTTPRequest(http.Request):
return state
def set_state(self, state):
state = state.copy()
self.is_replay = state.pop("is_replay")
super().set_state(state)

View File

@ -84,6 +84,17 @@ class TestSerialize:
with pytest.raises(Exception, match="version"):
list(r.stream())
def test_copy(self):
"""
_backup may be shared across instances. That should not raise errors.
"""
f = tflow.tflow()
f.backup()
f.request.path = "/foo"
f2 = f.copy()
f2.revert()
f.revert()
class TestFlowMaster:
def test_load_flow_reverse(self):