sklearn.utils.testing.assert_raise_message

sklearn.utils.testing.assert_raise_message(exceptions, message, function, *args, **kwargs)[source]

Helper function to test the message raised in an exception.

Given an exception, a callable to raise the exception, and a message string, tests that the correct exception is raised and that the message is a substring of the error thrown. Used to test that the specific message thrown during an exception is correct.

Parameters
exceptionsexception or tuple of exception

An Exception object.

messagestr

The error message or a substring of the error message.

functioncallable

Callable object to raise error.

*argsthe positional arguments to function.
**kwargsthe keyword arguments to function.