本文整理汇总了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