~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_email_message.py

  • Committer: John Arbash Meinel
  • Date: 2007-07-20 14:42:48 UTC
  • mto: This revision was merged to the branch mainline in revision 2641.
  • Revision ID: john@arbash-meinel.com-20070720144248-6qltqb2tkm9x49lw
Some cleanups for the EmailMessage class.
Remove self._msgobj as it can lead to reporting incorrect cached data.
Update tests for changes in python2.5, adding similar strings
into a dictionary, with one being unicode and the other string
causes a UnicodeWarning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
SIMPLE_MESSAGE_ASCII = _SIMPLE_MESSAGE % ('us-ascii', '7bit', 'body')
45
45
SIMPLE_MESSAGE_UTF8 = _SIMPLE_MESSAGE % ('utf-8', 'base64', 'YsOzZHk=\n')
46
 
SIMPLE_MESSAGE_8BIT = _SIMPLE_MESSAGE % ('8-bit', 'base64', 'YvNkeQ==\n')
 
46
SIMPLE_MESSAGE_8BIT = _SIMPLE_MESSAGE % ('8-bit', 'base64', 'YvRkeQ==\n')
47
47
 
48
48
 
49
49
BOUNDARY = '=====123456=='
94
94
            'body': SIMPLE_MESSAGE_ASCII,
95
95
            u'b\xf3dy': SIMPLE_MESSAGE_UTF8,
96
96
            'b\xc3\xb3dy': SIMPLE_MESSAGE_UTF8,
97
 
            'b\xf3dy': SIMPLE_MESSAGE_8BIT,
 
97
            'b\xf4dy': SIMPLE_MESSAGE_8BIT,
98
98
        }
99
99
        for body, expected in pairs.items():
100
100
            msg = EmailMessage('from@from.com', 'to@to.com', 'subject', body)
220
220
                u'P\xe9rez':    ('P\xc3\xa9rez', 'utf-8'),
221
221
                'Perez':         ('Perez', 'ascii'), # u'Pepe' == 'Pepe'
222
222
                'P\xc3\xa9rez': ('P\xc3\xa9rez', 'utf-8'),
223
 
                'P\xe9rez':     ('P\xe9rez', '8-bit'),
 
223
                'P\xe8rez':     ('P\xe8rez', '8-bit'),
224
224
        }
225
225
        for string_, pair in pairs.items():
226
226
            self.assertEqual(pair, EmailMessage.string_with_encoding(string_))