def _assert_contains(haystack, needle, invert, escape=False):
myneedle = re.escape(needle) if escape else needle<EOL>matched = re.search(myneedle, haystack, re.M)<EOL>if (invert and matched) or (not invert and not matched):<EOL><INDENT>raise AssertionError("<STR_LIT>" % (<EOL>needle,<EOL>"<STR_LIT>" if invert else "<STR_LIT>",<EOL>haystack<EOL>))<EOL><DEDENT>
Test for existence of ``needle`` regex within ``haystack``.

Say ``escape`` to escape the ``needle`` if you aren't really using the
regex feature & have special characters in it.