docs: def assert_raises_regex(exception, regex, msg_fmt="{msg}"):
      """Fail unless an exception with a message that matches a regular
       expression is raised within the context.
  
      The regular expression can be a regular expression string or object.
  
      >>> with assert_raises_regex(ValueError, r"\\d+"):
      ...     raise ValueError("Error #42")
      ...
      >>> with assert_raises_regex(ValueError, r"\\d+"):
      ...     raise ValueError("Generic Error")
      ...
      Traceback (most recent call last):
          ...
      AssertionError: 'Generic Error' does not match '\\\\d+'
  
      The following msg_fmt arguments are supported:
      * msg - the default error message
      * exc_type - exception type that is expected
      * exc_name - expected exception type name
      * text - actual error text
      * pattern - expected error message as regular expression string
      """
  
      def test(exc):
          compiled = re.compile(regex)
          if not exc.args:
              msg = "{} without message".format(exception.__name__)
              fail(
                  msg_fmt.format(
                      msg=msg,
                      text=None,
                      pattern=compiled.pattern,
                      exc_type=exception,
                      exc_name=exception.__name__,
                  )
              )
          text = exc.args[0]
          if not compiled.search(text):
              msg = "{!r} does not match {!r}".format(text, compiled.pattern)
              fail(
                  msg_fmt.format(
                      msg=msg,
                      text=text,
                      pattern=compiled.pattern,
                      exc_type=exception,
                      exc_name=exception.__name__,
                  )
              )
  
      context = AssertRaisesRegexContext(exception, regex, msg_fmt)
      context.add_test(test)
      return context