| 7 | |
| 8 | |
| 9 | async def test_reuse(): |
| 10 | async def handler(r, w): |
| 11 | pass |
| 12 | |
| 13 | server = await asyncio.start_server( |
| 14 | handler, host="127.0.0.1", port=0, reuse_address=False |
| 15 | ) |
| 16 | port = server.sockets[0].getsockname()[1] |
| 17 | master = WebMaster(Options(), with_termlog=False) |
| 18 | master.options.web_host = "127.0.0.1" |
| 19 | master.options.web_port = port |
| 20 | with pytest.raises(OSError, match=f"--set web_port={port + 2}"): |
| 21 | await master.running() |
| 22 | server.close() |
| 23 | # tornado registers some callbacks, |
| 24 | # we want to run them to avoid fatal warnings. |
| 25 | await asyncio.sleep(0) |