def assert_raise_message(exceptions, message, function, *args, **kwargs):
    """Helper function to test error messages in exceptions.

    Parameters
    ----------
    exceptions : exception or tuple of exception
        Name of the estimator

    func : callable
        Calable object to raise error

    *args : the positional arguments to `func`.

    **kw : the keyword arguments to `func`
    """
    try:
        function(*args, **kwargs)
    except exceptions as e:
        error_message = str(e)
        if error_message not in message:
            raise AssertionError("Error message does not include the expected"
                                 " string: %r. Observed error message: %r" %
                                 (message, error_message))
    else:
        # concatenate exception names
        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__))
dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/utils/testing.py/assert_raise_message/swapped operands of `not in`