MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / test_read

Method test_read

test/mitmproxy/addons/test_readfile.py:50–76  ·  view source on GitHub ↗
(self, tmpdir, data, corrupt_data, caplog_async)

Source from the content-addressed store, hash-verified

48 tctx.configure(rf, readfile_filter="")
49
50 async def test_read(self, tmpdir, data, corrupt_data, caplog_async):
51 rf = readfile.ReadFile()
52 with taddons.context(rf) as tctx:
53 assert not rf.reading()
54
55 tf = tmpdir.join("tfile")
56
57 load_called = asyncio.Event()
58
59 async def load_flow(*_, **__):
60 load_called.set()
61
62 tctx.master.load_flow = load_flow
63
64 tf.write(data.getvalue())
65 tctx.configure(rf, rfile=str(tf), readfile_filter=".*")
66 assert not load_called.is_set()
67 rf.running()
68 await load_called.wait()
69
70 while rf.reading():
71 await asyncio.sleep(0)
72
73 tf.write(corrupt_data.getvalue())
74 tctx.configure(rf, rfile=str(tf))
75 rf.running()
76 await caplog_async.await_log("corrupted")
77
78 async def test_corrupt(self, corrupt_data, caplog_async):
79 rf = readfile.ReadFile()

Callers

nothing calls this directly

Calls 9

readingMethod · 0.95
runningMethod · 0.95
contextMethod · 0.80
getvalueMethod · 0.80
waitMethod · 0.80
await_logMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45
configureMethod · 0.45

Tested by

no test coverage detected