MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_delitem

Function test_delitem

testing/test_monkeypatch.py:156–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

154
155
156def test_delitem() -> None:
157 d: Dict[str, object] = {"x": 1}
158 monkeypatch = MonkeyPatch()
159 monkeypatch.delitem(d, "x")
160 assert "x" not in d
161 monkeypatch.delitem(d, "y", raising=False)
162 pytest.raises(KeyError, monkeypatch.delitem, d, "y")
163 assert not d
164 monkeypatch.setitem(d, "y", 1700)
165 assert d["y"] == 1700
166 d["hello"] = "world"
167 monkeypatch.setitem(d, "x", 1500)
168 assert d["x"] == 1500
169 monkeypatch.undo()
170 assert d == {"hello": "world", "x": 1}
171
172
173def test_setenv() -> None:

Callers

nothing calls this directly

Calls 4

delitemMethod · 0.95
setitemMethod · 0.95
undoMethod · 0.95
MonkeyPatchClass · 0.90

Tested by

no test coverage detected