<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def assert_warns_regex(warning_type, regex, msg_fmt="{msg}"):
 """Fail unless a warning with a message is issued inside the context. The message can be a regular expression string or object. Traceback (most recent call last):
 AssertionError: no UserWarning matching 'Expected Error' issued The following msg_fmt arguments are supported: * msg - the default error message * exc_type - warning type * exc_name - warning type name * pattern - expected warning message as regular expression string """


    def test(warning):
        return re.search(regex, str(warning.message)) is not None

    context = AssertWarnsRegexContext(warning_type, regex, msg_fmt)
    context.add_test(test)
    return context