本文整理匯總了Python中email.Errors.HeaderParseError方法的典型用法代碼示例。如果您正苦於以下問題:Python Errors.HeaderParseError方法的具體用法?Python Errors.HeaderParseError怎麽用?Python Errors.HeaderParseError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類email.Errors
的用法示例。
在下文中一共展示了Errors.HeaderParseError方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_set_boundary
# 需要導入模塊: from email import Errors [as 別名]
# 或者: from email.Errors import HeaderParseError [as 別名]
def test_set_boundary(self):
eq = self.assertEqual
# This one has no existing boundary parameter, but the Content-Type:
# header appears fifth.
msg = self._msgobj('msg_01.txt')
msg.set_boundary('BOUNDARY')
header, value = msg.items()[4]
eq(header.lower(), 'content-type')
eq(value, 'text/plain; charset="us-ascii"; boundary="BOUNDARY"')
# This one has a Content-Type: header, with a boundary, stuck in the
# middle of its headers. Make sure the order is preserved; it should
# be fifth.
msg = self._msgobj('msg_04.txt')
msg.set_boundary('BOUNDARY')
header, value = msg.items()[4]
eq(header.lower(), 'content-type')
eq(value, 'multipart/mixed; boundary="BOUNDARY"')
# And this one has no Content-Type: header at all.
msg = self._msgobj('msg_03.txt')
self.assertRaises(Errors.HeaderParseError,
msg.set_boundary, 'BOUNDARY')
示例2: test_broken_base64_header
# 需要導入模塊: from email import Errors [as 別名]
# 或者: from email.Errors import HeaderParseError [as 別名]
def test_broken_base64_header(self):
raises = self.assertRaises
s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3IQ?='
raises(Errors.HeaderParseError, decode_header, s)
# Test RFC 2231 header parameters (en/de)coding
示例3: test_embeded_header_via_Header_rejected
# 需要導入模塊: from email import Errors [as 別名]
# 或者: from email.Errors import HeaderParseError [as 別名]
def test_embeded_header_via_Header_rejected(self):
msg = Message()
msg['Dummy'] = Header('dummy\nX-Injected-Header: test')
self.assertRaises(Errors.HeaderParseError, msg.as_string)
示例4: test_embeded_header_via_string_rejected
# 需要導入模塊: from email import Errors [as 別名]
# 或者: from email.Errors import HeaderParseError [as 別名]
def test_embeded_header_via_string_rejected(self):
msg = Message()
msg['Dummy'] = 'dummy\nX-Injected-Header: test'
self.assertRaises(Errors.HeaderParseError, msg.as_string)
# Test the email.Encoders module
示例5: test_broken_base64_header
# 需要導入模塊: from email import Errors [as 別名]
# 或者: from email.Errors import HeaderParseError [as 別名]
def test_broken_base64_header(self):
raises = self.assertRaises
s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?='
raises(Errors.HeaderParseError, decode_header, s)
# Issue 1078919
示例6: test_embedded_header_via_Header_rejected
# 需要導入模塊: from email import Errors [as 別名]
# 或者: from email.Errors import HeaderParseError [as 別名]
def test_embedded_header_via_Header_rejected(self):
msg = Message()
msg['Dummy'] = Header('dummy\nX-Injected-Header: test')
self.assertRaises(Errors.HeaderParseError, msg.as_string)
示例7: test_embedded_header_via_string_rejected
# 需要導入模塊: from email import Errors [as 別名]
# 或者: from email.Errors import HeaderParseError [as 別名]
def test_embedded_header_via_string_rejected(self):
msg = Message()
msg['Dummy'] = 'dummy\nX-Injected-Header: test'
self.assertRaises(Errors.HeaderParseError, msg.as_string)
# Test the email.Encoders module