1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
from collections import deque
from typing import Type
from multidict import MultiMapping
def test_update_replace(any_multidict_class: Type[MultiMapping[str]]) -> None:
obj1 = any_multidict_class([("a", 1), ("b", 2), ("a", 3), ("c", 10)])
obj2 = any_multidict_class([("a", 4), ("b", 5), ("a", 6)])
obj1.update(obj2)
expected = [("a", 4), ("b", 5), ("a", 6), ("c", 10)]
assert list(obj1.items()) == expected
def test_update_append(any_multidict_class: Type[MultiMapping[str]]) -> None:
obj1 = any_multidict_class([("a", 1), ("b", 2), ("a", 3), ("c", 10)])
obj2 = any_multidict_class([("a", 4), ("a", 5), ("a", 6)])
obj1.update(obj2)
expected = [("a", 4), ("b", 2), ("a", 5), ("c", 10), ("a", 6)]
assert list(obj1.items()) == expected
def test_update_remove(any_multidict_class: Type[MultiMapping[str]]) -> None:
obj1 = any_multidict_class([("a", 1), ("b", 2), ("a", 3), ("c", 10)])
obj2 = any_multidict_class([("a", 4)])
obj1.update(obj2)
expected = [("a", 4), ("b", 2), ("c", 10)]
assert list(obj1.items()) == expected
def test_update_replace_seq(any_multidict_class: Type[MultiMapping[str]]) -> None:
obj1 = any_multidict_class([("a", 1), ("b", 2), ("a", 3), ("c", 10)])
obj2 = [("a", 4), ("b", 5), ("a", 6)]
obj1.update(obj2)
expected = [("a", 4), ("b", 5), ("a", 6), ("c", 10)]
assert list(obj1.items()) == expected
def test_update_replace_seq2(any_multidict_class: Type[MultiMapping[str]]) -> None:
obj1 = any_multidict_class([("a", 1), ("b", 2), ("a", 3), ("c", 10)])
obj1.update([("a", 4)], b=5, a=6)
expected = [("a", 4), ("b", 5), ("a", 6), ("c", 10)]
assert list(obj1.items()) == expected
def test_update_append_seq(any_multidict_class: Type[MultiMapping[str]]) -> None:
obj1 = any_multidict_class([("a", 1), ("b", 2), ("a", 3), ("c", 10)])
obj2 = [("a", 4), ("a", 5), ("a", 6)]
obj1.update(obj2)
expected = [("a", 4), ("b", 2), ("a", 5), ("c", 10), ("a", 6)]
assert list(obj1.items()) == expected
def test_update_remove_seq(any_multidict_class: Type[MultiMapping[str]]) -> None:
obj1 = any_multidict_class([("a", 1), ("b", 2), ("a", 3), ("c", 10)])
obj2 = [("a", 4)]
obj1.update(obj2)
expected = [("a", 4), ("b", 2), ("c", 10)]
assert list(obj1.items()) == expected
def test_update_md(
case_sensitive_multidict_class: Type[MultiMapping[str]],
) -> None:
d = case_sensitive_multidict_class()
d.add("key", "val1")
d.add("key", "val2")
d.add("key2", "val3")
d.update(key="val")
assert [("key", "val"), ("key2", "val3")] == list(d.items())
def test_update_istr_ci_md(
case_insensitive_multidict_class: Type[MultiMapping[str]],
case_insensitive_str_class: str,
) -> None:
d = case_insensitive_multidict_class()
d.add(case_insensitive_str_class("KEY"), "val1")
d.add("key", "val2")
d.add("key2", "val3")
d.update({case_insensitive_str_class("key"): "val"})
assert [("key", "val"), ("key2", "val3")] == list(d.items())
def test_update_ci_md(
case_insensitive_multidict_class: Type[MultiMapping[str]],
) -> None:
d = case_insensitive_multidict_class()
d.add("KEY", "val1")
d.add("key", "val2")
d.add("key2", "val3")
d.update(Key="val")
assert [("Key", "val"), ("key2", "val3")] == list(d.items())
def test_update_list_arg_and_kwds(
any_multidict_class: Type[MultiMapping[str]],
) -> None:
obj = any_multidict_class()
arg = [("a", 1)]
obj.update(arg, b=2)
assert list(obj.items()) == [("a", 1), ("b", 2)]
assert arg == [("a", 1)]
def test_update_tuple_arg_and_kwds(
any_multidict_class: Type[MultiMapping[str]],
) -> None:
obj = any_multidict_class()
arg = (("a", 1),)
obj.update(arg, b=2)
assert list(obj.items()) == [("a", 1), ("b", 2)]
assert arg == (("a", 1),)
def test_update_deque_arg_and_kwds(
any_multidict_class: Type[MultiMapping[str]],
) -> None:
obj = any_multidict_class()
arg = deque([("a", 1)])
obj.update(arg, b=2)
assert list(obj.items()) == [("a", 1), ("b", 2)]
assert arg == deque([("a", 1)])
|