def parameter_space(__fail_fast=False, **params):
 def decorator(f):
  argspec = getargspec(f)
  if argspec.varargs:
   raise AssertionError("parameter_space() doesn't support *args")
  if argspec.keywords:
   raise AssertionError("parameter_space() doesn't support **kwargs")
  if argspec.defaults:
   raise AssertionError("parameter_space() doesn't support defaults.")
  argnames = argspec.args
  if (argnames[0] == 'self'):
   argnames = argnames[1:]
  extra = (set(params) - set(argnames))
  if extra:
   raise AssertionError(('Keywords %s supplied to parameter_space() are not in function signature.' % extra))
  unspecified = (set(argnames) - set(params))
  if unspecified:
   raise AssertionError(('Function arguments %s were not supplied to parameter_space().' % extra))
  param_sets = product(*(params[name] for name in argnames))
  if __fail_fast:
   @wraps(f)
   def wrapped(self):
    for args in param_sets:
     f(self, *args)
   return wrapped
  else:
   return subtest(param_sets, *argnames)(f)
 return decorator

def parameter_space ( __fail_fast = False , ** params ) : def decorator ( f ) : argspec = getargspec ( f ) if argspec . varargs : raise AssertionError ( "parameter_space() doesn't support *args" ) if argspec . keywords : raise AssertionError ( "parameter_space() doesn't support **kwargs" ) if argspec . defaults : raise AssertionError ( "parameter_space() doesn't support defaults." ) argnames = argspec . args if ( argnames [ 0 ] == 'self' ) : argnames = argnames [ 1 : ] extra = ( set ( params ) - set ( argnames ) ) if extra : raise AssertionError ( ( 'Keywords %s supplied to parameter_space() are not in function signature.' % extra ) ) unspecified = ( set ( argnames ) - set ( params ) ) if unspecified : raise AssertionError ( ( 'Function arguments %s were not supplied to parameter_space().' % extra ) ) param_sets = product ( * ( params [ name ] for name in argnames ) ) if __fail_fast : @ wraps ( f ) def wrapped ( self ) : for args in param_sets : f ( self , * args ) return wrapped else : return subtest ( param_sets , * argnames ) ( f ) return decorator
unpack a sequence of positional parameter spaces into the product of each space .