/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_email_message.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-02-14 03:16:54 UTC
  • mfrom: (7479.2.3 no-more-python2)
  • Revision ID: breezy.the.bot@gmail.com-20200214031654-bp1xtv2jr9nmhto3
Drop python2 support.

Merged from https://code.launchpad.net/~jelmer/brz/no-more-python2/+merge/378694

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from .. import __version__ as _breezy_version
21
21
from ..email_message import EmailMessage
22
22
from ..errors import BzrBadParameterNotUnicode
23
 
from ..sixish import PY3, text_type
24
23
from ..smtp_connection import SMTPConnection
25
24
from .. import tests
26
25
 
68
67
''' % {'version': _breezy_version, 'boundary': BOUNDARY}
69
68
 
70
69
 
71
 
def final_newline_or_not(msg):
72
 
    if sys.version_info >= (2, 7, 6):
73
 
        # Some internals of python's email module changed in an (minor)
74
 
        # incompatible way: a final newline is appended in 2.7.6...
75
 
        msg += '\n'
 
70
def simple_multipart_message():
 
71
    msg = _MULTIPART_HEAD + '--%s--\n' % BOUNDARY
76
72
    return msg
77
73
 
78
74
 
79
 
def simple_multipart_message():
80
 
    msg = _MULTIPART_HEAD + '--%s--' % BOUNDARY
81
 
    return final_newline_or_not(msg)
82
 
 
83
 
 
84
75
def complex_multipart_message(typ):
85
76
    msg = _MULTIPART_HEAD + '''\
86
77
--%(boundary)s
95
86
d
96
87
e
97
88
 
98
 
--%(boundary)s--''' % {'boundary': BOUNDARY}
99
 
    msg = final_newline_or_not(msg)
 
89
--%(boundary)s--
 
90
''' % {'boundary': BOUNDARY}
100
91
    return msg % (typ,)
101
92
 
102
93
 
170
161
    def test_address_to_encoded_header(self):
171
162
        def decode(s):
172
163
            """Convert a RFC2047-encoded string to a unicode string."""
173
 
            if PY3:
174
 
                return ''.join([chunk.decode(encoding or 'ascii')
175
 
                                for chunk, encoding in decode_header(s)])
176
 
            else:
177
 
                # Cope with python2 stripping whitespace.
178
 
                # https://bugs.python.org/issue1467619
179
 
                return ' '.join([chunk.decode(encoding or 'ascii')
180
 
                                 for chunk, encoding in decode_header(s)])
 
164
            return ''.join([chunk.decode(encoding or 'ascii')
 
165
                            for chunk, encoding in decode_header(s)])
181
166
 
182
167
        address = 'jrandom@example.com'
183
168
        encoded = EmailMessage.address_to_encoded_header(address)