def get_two_free_ports():
    with contextlib.closing(socket.socket()) as sock1:
        with contextlib.closing(socket.socket()) as sock2:
            sock1.bind(("", 0))
            sock2.bind(("", 0))

            return sock1.getsockname()[1], sock2.getsockname()[1]
Returns two free ports to use for the tests
dataset/ETHPy150Open letsencrypt/letsencrypt/certbot-compatibility-test/certbot_compatibility_test/util.py/get_two_free_ports