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

Method setitem

src/_pytest/monkeypatch.py:288–292  ·  src/_pytest/monkeypatch.py::MonkeyPatch.setitem

Set dictionary entry ``name`` to value.

(self, dic: Mapping[K, V], name: K, value: V)

Source from the content-addressed store, hash-verified

286 delattr(target, name)
287
288 def setitem(self, dic: Mapping[K, V], name: K, value: V) -> None:
289 class="st">""class="st">"Set dictionary entry ``name`` to value."class="st">""
290 self._setitem.append((dic, name, dic.get(name, NOTSET)))
291 class="cm"># Not all Mapping types support indexing, but MutableMapping doesn't support TypedDict
292 dic[name] = value class="cm"># type: ignore[index]
293
294 def delitem(self, dic: Mapping[K, V], name: K, raising: bool = True) -> None:
295 class="st">"""Delete ``name`` from dict.

Callers 15

setenvMethod · 0.95
test_setitemFunction · 0.95
test_delitemFunction · 0.95
test_add_removedMethod · 0.80
test_restore_reloadedMethod · 0.80
test_preserve_modulesMethod · 0.80
test_canonical_importMethod · 0.80

Calls 2

appendMethod · 0.80
getMethod · 0.45

Tested by 15

test_setitemFunction · 0.76
test_delitemFunction · 0.76
test_add_removedMethod · 0.64
test_restore_reloadedMethod · 0.64
test_preserve_modulesMethod · 0.64
test_canonical_importMethod · 0.64
test_importorskipFunction · 0.64