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


Python MimeHeaders.have_changed方法代碼示例

本文整理匯總了Python中flanker.mime.message.headers.MimeHeaders.have_changed方法的典型用法代碼示例。如果您正苦於以下問題:Python MimeHeaders.have_changed方法的具體用法?Python MimeHeaders.have_changed怎麽用?Python MimeHeaders.have_changed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flanker.mime.message.headers.MimeHeaders的用法示例。


在下文中一共展示了MimeHeaders.have_changed方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: headers_transform_test

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import have_changed [as 別名]
def headers_transform_test():
    headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')]

    h = MimeHeaders(headers)

    # transform tracks whether anything actually changed
    h.transform(lambda key,val: (key, val))
    assert_false(h.have_changed())

    # ok, now something have changed, make sure we've preserved order and did not collapse anything
    h.transform(lambda key,val: ("X-{0}".format(key), "t({0})".format(val)))
    ok_(h.have_changed())

    eq_([('X-Mime-Version', 't(1)'), ('X-Received', 't(2)'), ('X-Mime-Version', 't(3)'), ('X-Received', 't(4)')], h.items())
開發者ID:Appono,項目名稱:flanker,代碼行數:16,代碼來源:headers_test.py

示例2: headers_transform_test

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import have_changed [as 別名]
def headers_transform_test():
    headers = [("mime-version", "1"), ("rEceived", "2"), ("mime-version", "3"), ("ReceiveD", "4")]

    h = MimeHeaders(headers)

    # transform tracks whether anything actually changed
    h.transform(lambda key, val: (key, val))
    assert_false(h.have_changed())

    # ok, now something have changed, make sure we've preserved order and did not collapse anything
    h.transform(lambda key, val: ("X-{}".format(key), "t({})".format(val)))
    ok_(h.have_changed())

    eq_(
        [("X-Mime-Version", "t(1)"), ("X-Received", "t(2)"), ("X-Mime-Version", "t(3)"), ("X-Received", "t(4)")],
        h.items(),
    )
開發者ID:nickcatal,項目名稱:flanker,代碼行數:19,代碼來源:headers_test.py

示例3: headers_alternation_test

# 需要導入模塊: from flanker.mime.message.headers import MimeHeaders [as 別名]
# 或者: from flanker.mime.message.headers.MimeHeaders import have_changed [as 別名]
def headers_alternation_test():
    headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')]

    h = MimeHeaders(headers)
    assert_false(h.have_changed())

    h.prepend('Received', 'Yo')
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    del h['Mime-Version']
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h['Mime-Version'] = 'a'
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h.add('Mime-Version', 'a')
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h.getall('Mime-Version')
    h.get('o')
    assert_false(h.have_changed())
開發者ID:Appono,項目名稱:flanker,代碼行數:27,代碼來源:headers_test.py


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