def test_random_port(): # assume there will be a free port we could bind to in range [10000,11000) for x in range(10000, 11000): port = HTTPServer.get_random_port((x, x+1)) if port is not None: assert port == x break
def test_bad_port_range(): # assume there will be a free port we could bind to in range [10000,11000) with pytest.raises(Exception): HTTPServer.get_random_port((10001, 10000))