MCPcopy
hub / github.com/pallets/werkzeug / test_callback_dict_reads

Method test_callback_dict_reads

tests/test_datastructures.py:961–976  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

959 storage_class = ds.CallbackDict
960
961 def test_callback_dict_reads(self):
962 assert_calls, func = make_call_asserter()
963 initial = {"a": "foo", "b": "bar"}
964 dct = self.storage_class(initial=initial, on_update=func)
965 with assert_calls(0, "callback triggered by read-only method"):
966 # read-only methods
967 dct["a"]
968 dct.get("a")
969 pytest.raises(KeyError, lambda: dct["x"])
970 assert "a" in dct
971 list(iter(dct))
972 dct.copy()
973 with assert_calls(0, "callback triggered without modification"):
974 # methods that may write but don't
975 dct.pop("z", None)
976 dct.setdefault("a")
977
978 def test_callback_dict_writes(self):
979 assert_calls, func = make_call_asserter()

Callers

nothing calls this directly

Calls 6

make_call_asserterFunction · 0.85
listFunction · 0.50
getMethod · 0.45
copyMethod · 0.45
popMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected