File tree Expand file tree Collapse file tree 2 files changed +34
-3
lines changed
src/future/backports/email Expand file tree Collapse file tree 2 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -800,7 +800,7 @@ def set_boundary(self, boundary):
800
800
# There was no Content-Type header, and we don't know what type
801
801
# to set it to, so raise an exception.
802
802
raise errors .HeaderParseError ('No Content-Type header found' )
803
- newparams = []
803
+ newparams = list ()
804
804
foundp = False
805
805
for pk , pv in params :
806
806
if pk .lower () == 'boundary' :
@@ -814,10 +814,10 @@ def set_boundary(self, boundary):
814
814
# instead???
815
815
newparams .append (('boundary' , '"%s"' % boundary ))
816
816
# Replace the existing Content-Type header with the new value
817
- newheaders = []
817
+ newheaders = list ()
818
818
for h , v in self ._headers :
819
819
if h .lower () == 'content-type' :
820
- parts = []
820
+ parts = list ()
821
821
for k , v in newparams :
822
822
if v == '' :
823
823
parts .append (k )
Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ """Tests for multipart emails."""
3
+
4
+ from future .tests .base import unittest
5
+ import future .backports .email as email
6
+ import future .backports .email .mime .multipart
7
+ from future .builtins import list
8
+
9
+ class EmailMultiPartTests (unittest .TestCase ):
10
+ """Tests for handling multipart email Messages."""
11
+
12
+ def test_multipart_serialize_without_boundary (self ):
13
+ """Tests that serializing an empty multipart email does not fail."""
14
+ multipart_message = email .mime .multipart .MIMEMultipart ()
15
+ self .assertIsNot (multipart_message .as_string (), None )
16
+
17
+ def test_multipart_set_boundary_does_not_change_header_type (self ):
18
+ """
19
+ Tests that Message.set_boundary() does not cause Python2 errors.
20
+
21
+ In particular, tests that set_boundary does not cause the type of the
22
+ message headers list to be changed from the future built-in list.
23
+ """
24
+ multipart_message = email .mime .multipart .MIMEMultipart ()
25
+ headers_type = type (multipart_message ._headers )
26
+ self .assertEqual (headers_type , type (list ()))
27
+
28
+ boundary = '===============6387699881409002085=='
29
+ multipart_message .set_boundary (boundary )
30
+ headers_type = type (multipart_message ._headers )
31
+ self .assertEqual (headers_type , type (list ()))
You can’t perform that action at this time.
0 commit comments