def mk_test_name(name, value, index=0):
 trivial_types = (type(None), bool, str, int, float)
 try:
  trivial_types += (unicode,)
 except NameError:
  pass
 def is_trivial(value):
  if isinstance(value, trivial_types):
   return True
  if isinstance(value, (list, tuple)):
   return all(map(is_trivial, value))
  return False
 if (is_hash_randomized() and (not is_trivial(value))):
  return '{0}_{1}'.format(name, (index + 1))
 try:
  value = str(value)
 except UnicodeEncodeError:
  value = value.encode('ascii', 'backslashreplace')
 test_name = '{0}_{1}_{2}'.format(name, (index + 1), value)
 return re.sub('\\W|^(?=\\d)', '_', test_name)

def mk_test_name ( name , value , index = 0 ) : trivial_types = ( type ( None ) , bool , str , int , float ) try : trivial_types += ( unicode , ) except NameError : pass def is_trivial ( value ) : if isinstance ( value , trivial_types ) : return True if isinstance ( value , ( list , tuple ) ) : return all ( map ( is_trivial , value ) ) return False if ( is_hash_randomized ( ) and ( not is_trivial ( value ) ) ) : return '{0}_{1}' . format ( name , ( index + 1 ) ) try : value = str ( value ) except UnicodeEncodeError : value = value . encode ( 'ascii' , 'backslashreplace' ) test_name = '{0}_{1}_{2}' . format ( name , ( index + 1 ) , value ) return re . sub ( '\\W|^(?=\\d)' , '_' , test_name )
generate a new name for a test case .