Returns a free port for the test server to bind.
()
| 30 | |
| 31 | @pytest.fixture(scope="session") |
| 32 | def free_port() -> int: |
| 33 | """Returns a free port for the test server to bind.""" |
| 34 | with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: |
| 35 | s.bind(("", 0)) |
| 36 | s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
| 37 | return s.getsockname()[1] |
| 38 | |
| 39 | |
| 40 | def run_server(port: int): |
nothing calls this directly
no outgoing calls
no test coverage detected