def harness(testdir_from_ns={None: os.curdir}, argv=sys.argv, setup_func=None, default_tags=None):
 if (not logging.root.handlers):
  logging.basicConfig()
 try:
  (log_level, action, tags) = _parse_opts(argv[1:], (default_tags or []))
 except getopt.error:
  (_, ex, _) = sys.exc_info()
  log.error((str(ex) + " (did you need a '--' before a '-TAG' argument?)"))
  return 1
 log.setLevel(log_level)
 if (action == 'help'):
  print __doc__
  return 0
 if (action == 'list'):
  return list_tests(testdir_from_ns, tags)
 elif (action == 'test'):
  result = test(testdir_from_ns, tags, setup_func=setup_func)
  if (result is None):
   return None
  return (len(result.errors) + len(result.failures))
 else:
  raise TestError(("unexpected action/mode: '%s'" % action))

def harness ( testdir_from_ns = { None : os . curdir } , argv = sys . argv , setup_func = None , default_tags = None ) : if ( not logging . root . handlers ) : logging . basicConfig ( ) try : ( log_level , action , tags ) = _parse_opts ( argv [ 1 : ] , ( default_tags or [ ] ) ) except getopt . error : ( _ , ex , _ ) = sys . exc_info ( ) log . error ( ( str ( ex ) + " (did you need a '--' before a '-TAG' argument?)" ) ) return 1 log . setLevel ( log_level ) if ( action == 'help' ) : print __doc__ return 0 if ( action == 'list' ) : return list_tests ( testdir_from_ns , tags ) elif ( action == 'test' ) : result = test ( testdir_from_ns , tags , setup_func = setup_func ) if ( result is None ) : return None return ( len ( result . errors ) + len ( result . failures ) ) else : raise TestError ( ( "unexpected action/mode: '%s'" % action ) )
convenience mainline for a test harness "test .