def check_pairs(func, pairs):
 name = getattr(func, 'func_name', getattr(func, '__name__', '<unknown>'))
 for (inp, expected) in pairs:
  out = func(inp)
  assert (out == expected), pair_fail_msg.format(name, inp, expected, out)

def check_pairs ( func , pairs ) : name = getattr ( func , 'func_name' , getattr ( func , '__name__' , '<unknown>' ) ) for ( inp , expected ) in pairs : out = func ( inp ) assert ( out == expected ) , pair_fail_msg . format ( name , inp , expected , out )
utility function for the common case of checking a function with a sequence of input/output pairs .