@nottest
def subtest(iterator, *_names):
 def dec(f):
  @wraps(f)
  def wrapped(*args, **kwargs):
   names = _names
   failures = []
   for scope in iterator:
    scope = tuple(scope)
    try:
     f(*(args + scope), **kwargs)
    except Exception as e:
     if (not names):
      names = count()
     failures.append((dict(zip(names, scope)), e))
   if failures:
    raise SubTestFailures(*failures)
  return wrapped
 return dec

@ nottest def subtest ( iterator , * _names ) : def dec ( f ) : @ wraps ( f ) def wrapped ( * args , ** kwargs ) : names = _names failures = [ ] for scope in iterator : scope = tuple ( scope ) try : f ( * ( args + scope ) , ** kwargs ) except Exception as e : if ( not names ) : names = count ( ) failures . append ( ( dict ( zip ( names , scope ) ) , e ) ) if failures : raise SubTestFailures ( * failures ) return wrapped return dec
construct a subtest in a unittest .