'Fail the test unless the text matches the regular expression.'

def assertRegexpMatches(self, text, expected_regexp, msg=None):

    if isinstance(expected_regexp, basestring):
        expected_regexp = re.compile(expected_regexp)
    if (not expected_regexp.search(text)):
        msg = (msg or "Regexp    didn't    match")
        msg = ('%s:    %r    not    found    in    %r' % (msg, expected_regexp.pattern, text))
        raise self.failureException(msg)
