def test_returns_an_open_port(self, port_min, port_max): """ get_available_port() should return an open port within the range """ port = common.get_available_port(port_min, port_max) assert port_min <= port <= port_max with socket.socket() as tmpsock: tmpsock.bind(('127.0.0.1', port))
def test_get_available_port_returns_an_open_port(): """get_available_port() should return an open port within the range""" for i in range(100): port = common.get_available_port(1024, 2048) assert 1024 <= port <= 2048 socket.socket().bind(("127.0.0.1", port))