def METHOD_NAME(self, regex, fun, *args):
    # TODO: assertRaisesRegex() would be useful here.
    with self.assertRaises(TypeError) as raise_context:
        fun(*args)
    if raise_context.exception is not None:
        exception_msg = str(raise_context.exception)
        if not re.search(regex, exception_msg):
            self.fail(f"exception matching '{regex}' not raised:"
                      f" '{exception_msg}'")