@pytest.fixture()
def execute_task(manager):
 def execute(task_name, abort=False, options=None):
  u'\n        Use to execute one test task from config.\n\n        :param abort: If `True` expect (and require) this task to abort.\n        '
  log.info((u'********** Running task: %s ********** ' % task_name))
  config = manager.config[u'tasks'][task_name]
  task = Task(manager, task_name, config=config, options=options)
  try:
   if abort:
    with pytest.raises(TaskAbort):
     task.execute()
   else:
    task.execute()
  finally:
   try:
    task.session.close()
   except Exception:
    pass
  return task
 return execute

@ pytest . fixture ( ) def execute_task ( manager ) : def execute ( task_name , abort = False , options = None ) : log . info ( ( u'********** Running task: %s ********** ' % task_name ) ) config = manager . config [ u'tasks' ] [ task_name ] task = Task ( manager , task_name , config = config , options = options ) try : if abort : with pytest . raises ( TaskAbort ) : task . execute ( ) else : task . execute ( ) finally : try : task . session . close ( ) except Exception : pass return task return execute
a function that can be used to execute and return a named task in config argument .