def assert_raise_message(exceptions, message, function, *args, **kwargs):
 try:
  function(*args, **kwargs)
 except exceptions as e:
  error_message = str(e)
  if (message not in error_message):
   raise AssertionError(('Error message does not include the expected string: %r. Observed error message: %r' % (message, error_message)))
 else:
  if isinstance(exceptions, tuple):
   names = ' or '.join((e.__name__ for e in exceptions))
  else:
   names = exceptions.__name__
  raise AssertionError(('%s not raised by %s' % (names, function.__name__)))

def assert_raise_message ( exceptions , message , function , * args , ** kwargs ) : try : function ( * args , ** kwargs ) except exceptions as e : error_message = str ( e ) if ( message not in error_message ) : raise AssertionError ( ( 'Error message does not include the expected string: %r. Observed error message: %r' % ( message , error_message ) ) ) else : if isinstance ( exceptions , tuple ) : names = ' or ' . join ( ( e . __name__ for e in exceptions ) ) else : names = exceptions . __name__ raise AssertionError ( ( '%s not raised by %s' % ( names , function . __name__ ) ) )
helper function to test error messages in exceptions .