def get_test_subprocess(cmd=None, **kwds):
 kwds.setdefault('stdin', DEVNULL)
 kwds.setdefault('stdout', DEVNULL)
 if (cmd is None):
  assert (not os.path.exists(_TESTFN))
  pyline = 'from time import sleep;'
  pyline += ("open(r'%s', 'w').close();" % _TESTFN)
  pyline += 'sleep(60)'
  cmd = [PYTHON, '-c', pyline]
  sproc = subprocess.Popen(cmd, **kwds)
  wait_for_file(_TESTFN, delete_file=True, empty=True)
 else:
  sproc = subprocess.Popen(cmd, **kwds)
  wait_for_pid(sproc.pid)
 _subprocesses_started.add(sproc)
 return sproc

def get_test_subprocess ( cmd = None , ** kwds ) : kwds . setdefault ( 'stdin' , DEVNULL ) kwds . setdefault ( 'stdout' , DEVNULL ) if ( cmd is None ) : assert ( not os . path . exists ( _TESTFN ) ) pyline = 'from time import sleep;' pyline += ( "open(r'%s', 'w').close();" % _TESTFN ) pyline += 'sleep(60)' cmd = [ PYTHON , '-c' , pyline ] sproc = subprocess . Popen ( cmd , ** kwds ) wait_for_file ( _TESTFN , delete_file = True , empty = True ) else : sproc = subprocess . Popen ( cmd , ** kwds ) wait_for_pid ( sproc . pid ) _subprocesses_started . add ( sproc ) return sproc
return a subprocess .