aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/multidict/tests/test_guard.py
blob: 225da67c8d2feaa04d6bd4052fb7166c9d0b6d57 (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
from typing import Type

import pytest

from multidict import MultiMapping


def test_guard_items(
    case_sensitive_multidict_class: Type[MultiMapping[str]],
) -> None:
    md = case_sensitive_multidict_class({"a": "b"})
    it = iter(md.items())
    md["a"] = "c"
    with pytest.raises(RuntimeError):
        next(it)


def test_guard_keys(
    case_sensitive_multidict_class: Type[MultiMapping[str]],
) -> None:
    md = case_sensitive_multidict_class({"a": "b"})
    it = iter(md.keys())
    md["a"] = "c"
    with pytest.raises(RuntimeError):
        next(it)


def test_guard_values(
    case_sensitive_multidict_class: Type[MultiMapping[str]],
) -> None:
    md = case_sensitive_multidict_class({"a": "b"})
    it = iter(md.values())
    md["a"] = "c"
    with pytest.raises(RuntimeError):
        next(it)