MCPcopy Index your code
hub / github.com/python/cpython / test_set_boundary

Method test_set_boundary

Lib/test/test_email/test_email.py:185–205  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

183 eq(msg.get_boundary(), 'BOUNDARY')
184
185 def test_set_boundary(self):
186 eq = self.assertEqual
187 # This one has no existing boundary parameter, but the Content-Type:
188 # header appears fifth.
189 msg = self._msgobj('msg_01.txt')
190 msg.set_boundary('BOUNDARY')
191 header, value = msg.items()[4]
192 eq(header.lower(), 'content-type')
193 eq(value, 'text/plain; charset="us-ascii"; boundary="BOUNDARY"')
194 # This one has a Content-Type: header, with a boundary, stuck in the
195 # middle of its headers. Make sure the order is preserved; it should
196 # be fifth.
197 msg = self._msgobj('msg_04.txt')
198 msg.set_boundary('BOUNDARY')
199 header, value = msg.items()[4]
200 eq(header.lower(), 'content-type')
201 eq(value, 'multipart/mixed; boundary="BOUNDARY"')
202 # And this one has no Content-Type: header at all.
203 msg = self._msgobj('msg_03.txt')
204 self.assertRaises(errors.HeaderParseError,
205 msg.set_boundary, 'BOUNDARY')
206
207 def test_make_boundary(self):
208 msg = MIMEMultipart('form-data')

Callers

nothing calls this directly

Calls 6

eqFunction · 0.85
set_boundaryMethod · 0.80
_msgobjMethod · 0.45
itemsMethod · 0.45
lowerMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected