blob: 823cc1afb8cbedc6e17b7c8ec377685af17e7070 (
plain) (
blame)
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
|
import pytest
from multidict._compat import USE_EXTENSIONS
from multidict._multidict_py import MultiDict as PyMultiDict # noqa: E402
if USE_EXTENSIONS:
from multidict._multidict import MultiDict # type: ignore
@pytest.fixture(
params=([MultiDict] if USE_EXTENSIONS else []) + [PyMultiDict],
ids=(["MultiDict"] if USE_EXTENSIONS else []) + ["PyMultiDict"],
)
def cls(request):
return request.param
def test_guard_items(cls):
md = cls({"a": "b"})
it = iter(md.items())
md["a"] = "c"
with pytest.raises(RuntimeError):
next(it)
def test_guard_keys(cls):
md = cls({"a": "b"})
it = iter(md.keys())
md["a"] = "c"
with pytest.raises(RuntimeError):
next(it)
def test_guard_values(cls):
md = cls({"a": "b"})
it = iter(md.values())
md["a"] = "c"
with pytest.raises(RuntimeError):
next(it)
|