def wire_HTTPConnection_to_WSGI(host, app):
 class HTTPConnectionDecorator(object, ):
  'Decorator to mock the HTTPConecction class.\n\n        Wraps the real HTTPConnection class so that when you instantiate\n        the class you might instead get a fake instance.\n        '
  def __init__(self, wrapped):
   self.wrapped = wrapped
  def __call__(self, connection_host, *args, **kwargs):
   if (connection_host == host):
    return FakeHttplibConnection(app, host)
   else:
    return self.wrapped(connection_host, *args, **kwargs)
 oldHTTPConnection = http_client.HTTPConnection
 new_http_connection = HTTPConnectionDecorator(http_client.HTTPConnection)
 http_client.HTTPConnection = new_http_connection
 return oldHTTPConnection

def wire_HTTPConnection_to_WSGI ( host , app ) : class HTTPConnectionDecorator ( object , ) : def __init__ ( self , wrapped ) : self . wrapped = wrapped def __call__ ( self , connection_host , * args , ** kwargs ) : if ( connection_host == host ) : return FakeHttplibConnection ( app , host ) else : return self . wrapped ( connection_host , * args , ** kwargs ) oldHTTPConnection = http_client . HTTPConnection new_http_connection = HTTPConnectionDecorator ( http_client . HTTPConnection ) http_client . HTTPConnection = new_http_connection return oldHTTPConnection
monkeypatches httpconnection so that if you try to connect to host .