本文整理汇总了Python中flanker.mime.message.headers.MimeHeaders.items方法的典型用法代码示例。如果您正苦于以下问题:Python MimeHeaders.items方法的具体用法?Python MimeHeaders.items怎么用?Python MimeHeaders.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flanker.mime.message.headers.MimeHeaders
的用法示例。
在下文中一共展示了MimeHeaders.items方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: headers_case_insensitivity_test
# 需要导入模块: from flanker.mime.message.headers import MimeHeaders [as 别名]
# 或者: from flanker.mime.message.headers.MimeHeaders import items [as 别名]
def headers_case_insensitivity_test():
h = MimeHeaders()
h['Content-Type'] = 1
eq_(1, h['Content-Type'])
eq_(1, h['conTenT-TyPE'])
ok_('cOnTenT-TyPE' in h)
ok_('Content-Type' in h)
eq_(1, h.get('Content-Type'))
eq_(None, h.get('Content-Type2'))
eq_([('Content-Type', 1)], h.items())
示例2: headers_order_preserved_test
# 需要导入模块: from flanker.mime.message.headers import MimeHeaders [as 别名]
# 或者: from flanker.mime.message.headers.MimeHeaders import items [as 别名]
def headers_order_preserved_test():
headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')]
h = MimeHeaders(headers)
# various types of iterations
should_be = [('Mime-Version', '1'), ('Received', '2'), ('Mime-Version', '3'), ('Received', '4')]
eq_(should_be, h.items())
ok_(isinstance(h.items(), list))
eq_(should_be, [p for p in h.iteritems()])
# iterate over keys
keys = ['Mime-Version', 'Received', 'Mime-Version', 'Received']
eq_(keys, [p for p in h])
eq_(keys, h.keys())
示例3: headers_transform_test
# 需要导入模块: from flanker.mime.message.headers import MimeHeaders [as 别名]
# 或者: from flanker.mime.message.headers.MimeHeaders import items [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(),
)
示例4: headers_transform_test
# 需要导入模块: from flanker.mime.message.headers import MimeHeaders [as 别名]
# 或者: from flanker.mime.message.headers.MimeHeaders import items [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())