def server_and_port(resources):
 worked = False
 for port in xrange(4443, 4543):
  try:
   server = HTTPServer(('localhost', port), partial(RequestHandler, resources))
  except socket.error:
   pass
  else:
   worked = True
   server.socket = ssl.wrap_socket(server.socket, certfile=join(tests_dir(), 'certs', 'localhost', 'server.pem'), server_side=True)
   break
 if (not worked):
  raise RuntimeError("Couldn't find an unused socket for the testing HTTPS server.")
 return (server, port)

def server_and_port ( resources ) : worked = False for port in xrange ( 4443 , 4543 ) : try : server = HTTPServer ( ( 'localhost' , port ) , partial ( RequestHandler , resources ) ) except socket . error : pass else : worked = True server . socket = ssl . wrap_socket ( server . socket , certfile = join ( tests_dir ( ) , 'certs' , 'localhost' , 'server.pem' ) , server_side = True ) break if ( not worked ) : raise RuntimeError ( "Couldn't find an unused socket for the testing HTTPS server." ) return ( server , port )
return an unstarted https server and the port it will use .