/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

Support user.signingkey configuration variable in .git/config.

Merged from https://code.launchpad.net/~jelmer/brz/local-git-key/+merge/381000

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
23
24
from ..smtp_connection import SMTPConnection
24
25
from .. import tests
25
26
 
67
68
''' % {'version': _breezy_version, 'boundary': BOUNDARY}
68
69
 
69
70
 
 
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'
 
76
    return msg
 
77
 
 
78
 
70
79
def simple_multipart_message():
71
 
    msg = _MULTIPART_HEAD + '--%s--\n' % BOUNDARY
72
 
    return msg
 
80
    msg = _MULTIPART_HEAD + '--%s--' % BOUNDARY
 
81
    return final_newline_or_not(msg)
73
82
 
74
83
 
75
84
def complex_multipart_message(typ):
86
95
d
87
96
e
88
97
 
89
 
--%(boundary)s--
90
 
''' % {'boundary': BOUNDARY}
 
98
--%(boundary)s--''' % {'boundary': BOUNDARY}
 
99
    msg = final_newline_or_not(msg)
91
100
    return msg % (typ,)
92
101
 
93
102
 
161
170
    def test_address_to_encoded_header(self):
162
171
        def decode(s):
163
172
            """Convert a RFC2047-encoded string to a unicode string."""
164
 
            return ''.join([chunk.decode(encoding or 'ascii')
165
 
                            for chunk, encoding in decode_header(s)])
 
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)])
166
181
 
167
182
        address = 'jrandom@example.com'
168
183
        encoded = EmailMessage.address_to_encoded_header(address)