test_guard.py 816 B

1234567891011121314151617181920212223242526272829303132333435
  1. from typing import Type
  2. import pytest
  3. from multidict import MultiMapping
  4. def test_guard_items(
  5. case_sensitive_multidict_class: Type[MultiMapping[str]],
  6. ) -> None:
  7. md = case_sensitive_multidict_class({"a": "b"})
  8. it = iter(md.items())
  9. md["a"] = "c"
  10. with pytest.raises(RuntimeError):
  11. next(it)
  12. def test_guard_keys(
  13. case_sensitive_multidict_class: Type[MultiMapping[str]],
  14. ) -> None:
  15. md = case_sensitive_multidict_class({"a": "b"})
  16. it = iter(md.keys())
  17. md["a"] = "c"
  18. with pytest.raises(RuntimeError):
  19. next(it)
  20. def test_guard_values(
  21. case_sensitive_multidict_class: Type[MultiMapping[str]],
  22. ) -> None:
  23. md = case_sensitive_multidict_class({"a": "b"})
  24. it = iter(md.values())
  25. md["a"] = "c"
  26. with pytest.raises(RuntimeError):
  27. next(it)