def mimic_for_test(test_case):
 mimic_config = {'realtime': True, 'listen': '0', 'verbose': True}
 mimic_service = mimic_make_service(mimic_config)
 mimic_service.startService()
 test_case.addCleanup(mimic_service.stopService)
 [site_service] = mimic_service.services
 waiting_for_port = site_service._waitingForPort
 def stop_the_port(listening_port):
  test_case.addCleanup((lambda : listening_port.stopListening()))
  return listening_port
 listening = waiting_for_port.addCallback(stop_the_port)
 return listening

def mimic_for_test ( test_case ) : mimic_config = { 'realtime' : True , 'listen' : '0' , 'verbose' : True } mimic_service = mimic_make_service ( mimic_config ) mimic_service . startService ( ) test_case . addCleanup ( mimic_service . stopService ) [ site_service ] = mimic_service . services waiting_for_port = site_service . _waitingForPort def stop_the_port ( listening_port ) : test_case . addCleanup ( ( lambda : listening_port . stopListening ( ) ) ) return listening_port listening = waiting_for_port . addCallback ( stop_the_port ) return listening
start a mimic server in the background on an ephemeral port and return the port number .