def assert_finds_email(text, email=None): if email is None: email = text match = email_regex.search(text) assert match user, domain = match.groups() assert '%s@%s' % (user, domain) == email
def assert_no_email(text): assert not email_regex.search(text)