MCPcopy
hub / github.com/mitmproxy/mitmproxy / test_tcp_start_stop

Function test_tcp_start_stop

test/mitmproxy/proxy/test_mode_servers.py:79–98  ·  view source on GitHub ↗
(caplog_async)

Source from the content-addressed store, hash-verified

77
78
79async def test_tcp_start_stop(caplog_async):
80 caplog_async.set_level("INFO")
81 manager = MagicMock()
82
83 with taddons.context():
84 inst = ServerInstance.make("regular@127.0.0.1:0", manager)
85 await inst.start()
86 assert inst.last_exception is None
87 assert await caplog_async.await_log("proxy listening")
88
89 host, port, *_ = inst.listen_addrs[0]
90 reader, writer = await asyncio.open_connection(host, port)
91 assert await caplog_async.await_log("client connect")
92
93 writer.close()
94 await writer.wait_closed()
95 assert await caplog_async.await_log("client disconnect")
96
97 await inst.stop()
98 assert await caplog_async.await_log("stopped")
99
100
101async def test_tcp_timeout(caplog_async):

Callers

nothing calls this directly

Calls 8

set_levelMethod · 0.80
contextMethod · 0.80
await_logMethod · 0.80
open_connectionMethod · 0.80
makeMethod · 0.45
startMethod · 0.45
closeMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…