当前位置: 首页>>代码示例>>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;未经允许,请勿转载。