def test_different_marker_func(): assert emails( '*****@*****.**', lambda a, b: u'<{}|{}>'.format(a, b) ) == '<mailto:[email protected]|[email protected]>' assert emails( 'mailto:[email protected]', lambda a, b: u'<{}|{}>'.format(a, b) ) == '<mailto:[email protected]|mailto:[email protected]>'
def test_whole_message(): text = u"""Hey! Here is the address: test.com which should give you what you want, there is also [email protected] and [email protected] if you need. We can also try mailto:[email protected], mailto:[email protected] or hej@håkan.com? """ new_text = emails(text) expected_text = u"""Hey! Here is the address: test.com which should give you what you want, there is also <mailto:[email protected]> and <mailto:[email protected]> if you need. We can also try <mailto:[email protected]>, <mailto:[email protected]> or <mailto:hej@håkan.com>? """ assert new_text == expected_text
def test_tlds(): for tld in TLDs(): assert emails(u'test@example.{}'.format(tld)) == u'<mailto:test@example.{}>'.format(tld)
def test_email_vs_url(): assert emails('example.com') == 'example.com' assert emails('*****@*****.**') == '<mailto:[email protected]>'
def test_co_uk(): assert emails('*****@*****.**') == '<mailto:[email protected]>'
def test_unknown_tld(): assert emails('*****@*****.**') == '*****@*****.**'
def test_excludes_after_domain(): assert emails('[email protected]?') == '<mailto:[email protected]>?'
def test_unicode(): assert emails(u'рф@кто.рф') == u'<mailto:рф@кто.рф>'
def test_must_start_with_word_character(): assert emails('*****@*****.**') == '*****@*****.**'
def test_keep_mailto(): assert emails('mailto:[email protected]') == '<mailto:[email protected]>'
def test_add_mailto(): assert emails('*****@*****.**') == '<mailto:[email protected]>'