本文整理汇总了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())
示例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(),
)
示例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())