本文整理匯總了Python中hyper.common.headers.HTTPHeaderMap.items方法的典型用法代碼示例。如果您正苦於以下問題:Python HTTPHeaderMap.items方法的具體用法?Python HTTPHeaderMap.items怎麽用?Python HTTPHeaderMap.items使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hyper.common.headers.HTTPHeaderMap
的用法示例。
在下文中一共展示了HTTPHeaderMap.items方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_merge_header_map_dict
# 需要導入模塊: from hyper.common.headers import HTTPHeaderMap [as 別名]
# 或者: from hyper.common.headers.HTTPHeaderMap import items [as 別名]
def test_merge_header_map_dict(self):
h = HTTPHeaderMap([(b'hi', b'there')])
d = {'cat': 'dog'}
h.merge(d)
assert list(h.items()) == [
(b'hi', b'there'),
(b'cat', b'dog'),
]
示例2: test_items
# 需要導入模塊: from hyper.common.headers import HTTPHeaderMap [as 別名]
# 或者: from hyper.common.headers.HTTPHeaderMap import items [as 別名]
def test_items(self):
h = HTTPHeaderMap()
items = [
(b'k1', b'v2'),
(b'k2', b'v2'),
(b'k2', b'v3'),
]
for k, v in items:
h[k] = v
for i, pair in enumerate(h.items()):
assert items[i] == pair
示例3: test_replacing
# 需要導入模塊: from hyper.common.headers import HTTPHeaderMap [as 別名]
# 或者: from hyper.common.headers.HTTPHeaderMap import items [as 別名]
def test_replacing(self):
h = HTTPHeaderMap([
(b'name', b'value'),
(b'name2', b'value2'),
(b'name2', b'value2'),
(b'name3', b'value3'),
])
h.replace('name2', '42')
h.replace('name4', 'other_value')
assert list(h.items()) == [
(b'name', b'value'),
(b'name2', b'42'),
(b'name3', b'value3'),
(b'name4', b'other_value'),
]