當前位置: 首頁>>代碼示例>>Python>>正文


Python Errors.HeaderParseError方法代碼示例

本文整理匯總了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') 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:23,代碼來源:test_email.py

示例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 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:10,代碼來源:test_email.py

示例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) 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:6,代碼來源:test_email.py

示例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 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:9,代碼來源:test_email.py

示例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 
開發者ID:adde88,項目名稱:hostapd-mana,代碼行數:8,代碼來源:test_email.py

示例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) 
開發者ID:oilshell,項目名稱:oil,代碼行數:6,代碼來源:test_email.py

示例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 
開發者ID:oilshell,項目名稱:oil,代碼行數:9,代碼來源:test_email.py


注:本文中的email.Errors.HeaderParseError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。