def SetupSimAfter(fname):
 _IOS_FNAME = fname
 _IOS_FNAME_BACKUP = ('%s.backup' % fname)
 _IOS_FNAME_TEMP = ('%s.temp' % fname)
 _SNAPSHOTS_BACKUP_PATH = os.path.join(_SNAPSHOTS_PATH, _IOS_FNAME_BACKUP)
 ios_sim_path = ('/Users/%s/Library/Application Support/iPhone Simulator/%s/' % (os.environ['USER'], _SCHEME['ios']))
 ios_fname_path = os.path.join(ios_sim_path, _IOS_FNAME)
 ios_fname_temp_path = os.path.join(ios_sim_path, _IOS_FNAME_TEMP)
 try:
  shutil.move(ios_fname_path, ios_fname_temp_path)
  shutil.copytree(_SNAPSHOTS_BACKUP_PATH, ios_fname_path)
  shutil.rmtree(ios_fname_temp_path, True, None)
  shutil.rmtree(_SNAPSHOTS_BACKUP_PATH, True, None)
 except EnvironmentError as e:
  print ('An error occurred in SetupSimAfter(%s). %s' % (fname, e))
  raise
 else:
  print ('SetupSimAfter(%s) successful.' % fname)
  return 1

def SetupSimAfter ( fname ) : _IOS_FNAME = fname _IOS_FNAME_BACKUP = ( '%s.backup' % fname ) _IOS_FNAME_TEMP = ( '%s.temp' % fname ) _SNAPSHOTS_BACKUP_PATH = os . path . join ( _SNAPSHOTS_PATH , _IOS_FNAME_BACKUP ) ios_sim_path = ( '/Users/%s/Library/Application Support/iPhone Simulator/%s/' % ( os . environ [ 'USER' ] , _SCHEME [ 'ios' ] ) ) ios_fname_path = os . path . join ( ios_sim_path , _IOS_FNAME ) ios_fname_temp_path = os . path . join ( ios_sim_path , _IOS_FNAME_TEMP ) try : shutil . move ( ios_fname_path , ios_fname_temp_path ) shutil . copytree ( _SNAPSHOTS_BACKUP_PATH , ios_fname_path ) shutil . rmtree ( ios_fname_temp_path , True , None ) shutil . rmtree ( _SNAPSHOTS_BACKUP_PATH , True , None ) except EnvironmentError as e : print ( 'An error occurred in SetupSimAfter(%s). %s' % ( fname , e ) ) raise else : print ( 'SetupSimAfter(%s) successful.' % fname ) return 1
replace the environments ios simulators media directory with what it was before the test took place .