def assertRegexpMatches(self, text, expected_regexp, msg=None):
if isinstance(expected_regexp, str):<EOL><INDENT>expected_regexp = re.compile(expected_regexp)<EOL><DEDENT>if not expected_regexp.search(text):<EOL><INDENT>msg = msg or "<STR_LIT>"<EOL>msg = '<STR_LIT>' % (msg, expected_regexp.pattern, text)<EOL>raise self.failureException(msg)<EOL><DEDENT>
Fail the test unless the text matches the regular expression.