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

Function test_setitem

testing/test_monkeypatch.py:113–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111
112
113def test_setitem() -> None:
114 d = {"x": 1}
115 monkeypatch = MonkeyPatch()
116 monkeypatch.setitem(d, "x", 2)
117 monkeypatch.setitem(d, "y", 1700)
118 monkeypatch.setitem(d, "y", 1700)
119 assert d["x"] == 2
120 assert d["y"] == 1700
121 monkeypatch.setitem(d, "x", 3)
122 assert d["x"] == 3
123 monkeypatch.undo()
124 assert d["x"] == 1
125 assert "y" not in d
126 d["x"] = 5
127 monkeypatch.undo()
128 assert d["x"] == 5
129
130
131def 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