def run_tests_in_emulator(package):
 env_vars = PACKAGE_INFO[package]
 start_command = get_start_command(package)
 proc_start = subprocess.Popen(start_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 try:
  wait_ready(package, proc_start)
  env_init_command = get_env_init_command(package)
  proc_env = subprocess.Popen(env_init_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  env_status = proc_env.wait()
  if (env_status != 0):
   raise RuntimeError(env_status, proc_env.stderr.read())
  env_lines = proc_env.stdout.read().strip().split('\n')
  for env_var in env_vars:
   line_prefix = (('export ' + env_var) + '=')
   (value,) = [line.split(line_prefix, 1)[1] for line in env_lines if line.startswith(line_prefix)]
   os.environ[env_var] = value
  run_module_tests(package, ignore_requirements=True)
 finally:
  cleanup(proc_start.pid)

def run_tests_in_emulator ( package ) : env_vars = PACKAGE_INFO [ package ] start_command = get_start_command ( package ) proc_start = subprocess . Popen ( start_command , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) try : wait_ready ( package , proc_start ) env_init_command = get_env_init_command ( package ) proc_env = subprocess . Popen ( env_init_command , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) env_status = proc_env . wait ( ) if ( env_status != 0 ) : raise RuntimeError ( env_status , proc_env . stderr . read ( ) ) env_lines = proc_env . stdout . read ( ) . strip ( ) . split ( '\n' ) for env_var in env_vars : line_prefix = ( ( 'export ' + env_var ) + '=' ) ( value , ) = [ line . split ( line_prefix , 1 ) [ 1 ] for line in env_lines if line . startswith ( line_prefix ) ] os . environ [ env_var ] = value run_module_tests ( package , ignore_requirements = True ) finally : cleanup ( proc_start . pid )
spawn an emulator instance and run the system tests .