def deterministicResolvingReactor(reactor, expectedAddresses=(), hostMap=None):
 if (hostMap is None):
  hostMap = {}
 hostMap = hostMap.copy()
 @provider(IHostnameResolver)
 class SimpleNameResolver(object, ):
  @staticmethod
  def resolveHostName(resolutionReceiver, hostName, portNumber=0, addressTypes=None, transportSemantics='TCP'):
   resolutionReceiver.resolutionBegan(None)
   for expectedAddress in hostMap.get(hostName, expectedAddresses):
    if isinstance(expectedAddress, str):
     expectedAddress = [IPv4Address, IPv6Address][isIPv6Address(expectedAddress)]('TCP', expectedAddress, portNumber)
    resolutionReceiver.addressResolved(expectedAddress)
   resolutionReceiver.resolutionComplete()
 @provider(IReactorPluggableNameResolver)
 class WithResolver(proxyForInterface(InterfaceClass('*', tuple(providedBy(reactor)))), ):
  nameResolver = SimpleNameResolver()
 return WithResolver(reactor)

def deterministicResolvingReactor ( reactor , expectedAddresses = ( ) , hostMap = None ) : if ( hostMap is None ) : hostMap = { } hostMap = hostMap . copy ( ) @ provider ( IHostnameResolver ) class SimpleNameResolver ( object , ) : @ staticmethod def resolveHostName ( resolutionReceiver , hostName , portNumber = 0 , addressTypes = None , transportSemantics = 'TCP' ) : resolutionReceiver . resolutionBegan ( None ) for expectedAddress in hostMap . get ( hostName , expectedAddresses ) : if isinstance ( expectedAddress , str ) : expectedAddress = [ IPv4Address , IPv6Address ] [ isIPv6Address ( expectedAddress ) ] ( 'TCP' , expectedAddress , portNumber ) resolutionReceiver . addressResolved ( expectedAddress ) resolutionReceiver . resolutionComplete ( ) @ provider ( IReactorPluggableNameResolver ) class WithResolver ( proxyForInterface ( InterfaceClass ( '*' , tuple ( providedBy ( reactor ) ) ) ) , ) : nameResolver = SimpleNameResolver ( ) return WithResolver ( reactor )
create a reactor that will deterministically resolve all hostnames it is passed to the list of addresses given .