def test_lazy_translated():
    # prepare translations
    T = gettext.GNUTranslations()
    T._catalog = {'invitation': 'invitaci\xf3n'}
    _ = T.gettext

    msg = Message(html='...', subject=lazy_string(_, 'invitation'))
    assert decode_header(msg.as_message()['subject']) == _('invitation')

    msg = Message(html='...', subject='invitaci\xf3n')
    assert decode_header(msg.as_message()['subject']) == 'invitaci\xf3n'
Exemple #2
0
def test_headers_not_double_encoded():

    TEXT = '웃'

    m = Message()
    m.mail_from = (TEXT, '[email protected]')
    m.mail_to = (TEXT, '[email protected]')
    m.subject = TEXT
    m.html = '...'
    msg = m.as_message()
    assert decode_header(parseaddr(msg['From'])[0]) == TEXT
    assert decode_header(parseaddr(msg['To'])[0]) == TEXT
    assert decode_header(msg['Subject']) == TEXT
Exemple #3
0
def test_headers_not_double_encoded():

    TEXT = '웃'

    m = Message()
    m.mail_from = (TEXT, '[email protected]')
    m.mail_to = (TEXT, '[email protected]')
    m.subject = TEXT
    m.html = '...'
    msg = m.as_message()
    assert decode_header(parseaddr(msg['From'])[0]) == TEXT
    assert decode_header(parseaddr(msg['To'])[0]) == TEXT
    assert decode_header(msg['Subject']) == TEXT
def test_header_encode():
    v = 'Мама мыла раму. ' * 30
    assert decode_header(encode_header(v)).strip() == v.strip()
    assert encode_header(1) == 1