| 33 | |
| 34 | class TestSerialize: |
| 35 | def test_roundtrip(self): |
| 36 | sio = io.BytesIO() |
| 37 | f = tflow.tflow() |
| 38 | f.marked = ":default:" |
| 39 | f.marked = True |
| 40 | f.comment = "test comment" |
| 41 | f.request.content = bytes(range(256)) |
| 42 | w = mitmproxy.io.FlowWriter(sio) |
| 43 | w.add(f) |
| 44 | |
| 45 | sio.seek(0) |
| 46 | r = mitmproxy.io.FlowReader(sio) |
| 47 | lst = list(r.stream()) |
| 48 | assert len(lst) == 1 |
| 49 | |
| 50 | f2 = lst[0] |
| 51 | assert f2.get_state() == f.get_state() |
| 52 | assert f2.request.data == f.request.data |
| 53 | assert f2.marked |
| 54 | assert f2.comment == "test comment" |
| 55 | |
| 56 | def test_filter(self): |
| 57 | sio = io.BytesIO() |