def _CheckRaises(self, exc_class, callable_obj, exception):
    """This method checks if the exception type and message are as expected."""
    try:
      callable_obj()
    except exc_class as ex:
      # Check if the exception message is the right one.
      self.assertEqual(exception, str(ex))
      return
    else:
      raise self.failureException('%s not raised' % str(exc_class))
This method checks if the exception type and message are as expected.
deps/protobuf/python/google/protobuf/internal/reflection_test.py