def init_test(options, testdir):
 locals_dict = locals().copy()
 globals_dict = globals().copy()
 locals_dict['testdir'] = testdir
 job = setup_job(options=options)
 locals_dict['job'] = job
 test_name = os.path.split(testdir)[(-1)]
 outputdir = os.path.join(job.resultdir, test_name)
 try:
  os.makedirs(outputdir)
 except OSError:
  pass
 locals_dict['outputdir'] = outputdir
 sys.path.insert(0, testdir)
 client_test = None
 try:
  import_stmt = ('import %s' % test_name)
  init_stmt = ('auto_test = %s.%s(job, testdir, outputdir)' % (test_name, test_name))
  exec ((import_stmt + '\n') + init_stmt) in locals_dict, globals_dict
  client_test = globals_dict['auto_test']
 except ImportError as e:
  if re.search(test_name, str(e)):
   pass
  else:
   logging.error(('%s import error: %s.  Skipping %s' % (test_name, e, test_name)))
 except Exception as e:
  logging.error('%s: %s', test_name, e)
 finally:
  sys.path.pop(0)
 return client_test

def init_test ( options , testdir ) : locals_dict = locals ( ) . copy ( ) globals_dict = globals ( ) . copy ( ) locals_dict [ 'testdir' ] = testdir job = setup_job ( options = options ) locals_dict [ 'job' ] = job test_name = os . path . split ( testdir ) [ ( - 1 ) ] outputdir = os . path . join ( job . resultdir , test_name ) try : os . makedirs ( outputdir ) except OSError : pass locals_dict [ 'outputdir' ] = outputdir sys . path . insert ( 0 , testdir ) client_test = None try : import_stmt = ( 'import %s' % test_name ) init_stmt = ( 'auto_test = %s.%s(job, testdir, outputdir)' % ( test_name , test_name ) ) exec ( ( import_stmt + '\n' ) + init_stmt ) in locals_dict , globals_dict client_test = globals_dict [ 'auto_test' ] except ImportError as e : if re . search ( test_name , str ( e ) ) : pass else : logging . error ( ( '%s import error: %s.  Skipping %s' % ( test_name , e , test_name ) ) ) except Exception as e : logging . error ( '%s: %s' , test_name , e ) finally : sys . path . pop ( 0 ) return client_test
instantiate a client test object from a given test directory .