MCPcopy
hub / github.com/pytest-dev/pytest / test_setitem

Function test_setitem

testing/test_monkeypatch.py:138–153  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

136
137
138def test_setitem() -> None:
139 d = {"x": 1}
140 monkeypatch = MonkeyPatch()
141 monkeypatch.setitem(d, "x", 2)
142 monkeypatch.setitem(d, "y", 1700)
143 monkeypatch.setitem(d, "y", 1700)
144 assert d["x"] == 2
145 assert d["y"] == 1700
146 monkeypatch.setitem(d, "x", 3)
147 assert d["x"] == 3
148 monkeypatch.undo()
149 assert d["x"] == 1
150 assert "y" not in d
151 d["x"] = 5
152 monkeypatch.undo()
153 assert d["x"] == 5
154
155
156def test_setitem_deleted_meanwhile() -> None:

Callers

nothing calls this directly

Calls 3

setitemMethod · 0.95
undoMethod · 0.95
MonkeyPatchClass · 0.90

Tested by

no test coverage detected