@@ -140,6 +140,39 @@ def test_flatten_linesep_overrides_policy(self):
140
140
g .flatten (msg , linesep = '\n ' )
141
141
self .assertEqual (s .getvalue (), self .typ (expected ))
142
142
143
+ def test_flatten_linesep (self ):
144
+ source = 'Subject: one\n two\r three\r \n four\r \n \r \n test body\r \n '
145
+ msg = self .msgmaker (self .typ (source ))
146
+ self .assertEqual (msg ['Subject' ], 'one two three four' )
147
+
148
+ expected = 'Subject: one\n two\n three\n four\n \n test body\n '
149
+ s = self .ioclass ()
150
+ g = self .genclass (s )
151
+ g .flatten (msg )
152
+ self .assertEqual (s .getvalue (), self .typ (expected ))
153
+
154
+ expected = 'Subject: one two three four\n \n test body\n '
155
+ s = self .ioclass ()
156
+ g = self .genclass (s , policy = self .policy .clone (refold_source = 'all' ))
157
+ g .flatten (msg )
158
+ self .assertEqual (s .getvalue (), self .typ (expected ))
159
+
160
+ def test_flatten_control_linesep (self ):
161
+ source = 'Subject: one\v two\f three\x1c four\x1d five\x1e six\r \n \r \n test body\r \n '
162
+ msg = self .msgmaker (self .typ (source ))
163
+ self .assertEqual (msg ['Subject' ], 'one\v two\f three\x1c four\x1d five\x1e six' )
164
+
165
+ expected = 'Subject: one\v two\f three\x1c four\x1d five\x1e six\n \n test body\n '
166
+ s = self .ioclass ()
167
+ g = self .genclass (s )
168
+ g .flatten (msg )
169
+ self .assertEqual (s .getvalue (), self .typ (expected ))
170
+
171
+ s = self .ioclass ()
172
+ g = self .genclass (s , policy = self .policy .clone (refold_source = 'all' ))
173
+ g .flatten (msg )
174
+ self .assertEqual (s .getvalue (), self .typ (expected ))
175
+
143
176
def test_set_mangle_from_via_policy (self ):
144
177
source = textwrap .dedent ("""\
145
178
Subject: test that
@@ -224,6 +257,22 @@ class TestGenerator(TestGeneratorBase, TestEmailBase):
224
257
ioclass = io .StringIO
225
258
typ = str
226
259
260
+ def test_flatten_unicode_linesep (self ):
261
+ source = 'Subject: one\x85 two\u2028 three\u2029 four\r \n \r \n test body\r \n '
262
+ msg = self .msgmaker (self .typ (source ))
263
+ self .assertEqual (msg ['Subject' ], 'one\x85 two\u2028 three\u2029 four' )
264
+
265
+ expected = 'Subject: =?utf-8?b?b25lwoUgdHdv4oCoIHRocmVl4oCp?= four\n \n test body\n '
266
+ s = self .ioclass ()
267
+ g = self .genclass (s )
268
+ g .flatten (msg )
269
+ self .assertEqual (s .getvalue (), self .typ (expected ))
270
+
271
+ s = self .ioclass ()
272
+ g = self .genclass (s , policy = self .policy .clone (refold_source = 'all' ))
273
+ g .flatten (msg )
274
+ self .assertEqual (s .getvalue (), self .typ (expected ))
275
+
227
276
228
277
class TestBytesGenerator (TestGeneratorBase , TestEmailBase ):
229
278
0 commit comments