def webserver_for_test(test, url_path, response_content):
 app = Klein()
 @app.route(url_path)
 def _respond(request):
  return response_content
 factory = Site(app.resource())
 endpoint = serverFromString(reactor, 'tcp:0')
 listening = endpoint.listen(factory)
 def stop_port(port):
  test.addCleanup(port.stopListening)
  return port
 listening.addCallback(stop_port)
 return listening

def webserver_for_test ( test , url_path , response_content ) : app = Klein ( ) @ app . route ( url_path ) def _respond ( request ) : return response_content factory = Site ( app . resource ( ) ) endpoint = serverFromString ( reactor , 'tcp:0' ) listening = endpoint . listen ( factory ) def stop_port ( port ) : test . addCleanup ( port . stopListening ) return port listening . addCallback ( stop_port ) return listening
create a webserver that serves response_content from url_path .