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

Method delitem

src/_pytest/monkeypatch.py:269–280  ·  view source on GitHub ↗

Delete ``name`` from dict. Raises ``KeyError`` if it doesn't exist, unless ``raising`` is set to False.

(self, dic: MutableMapping[K, V], name: K, raising: bool = True)

Source from the content-addressed store, hash-verified

267 dic[name] = value
268
269 def delitem(self, dic: MutableMapping[K, V], name: K, raising: bool = True) -> None:
270 """Delete ``name`` from dict.
271
272 Raises ``KeyError`` if it doesn't exist, unless ``raising`` is set to
273 False.
274 """
275 if name not in dic:
276 if raising:
277 raise KeyError(name)
278 else:
279 self._setitem.append((dic, name, dic.get(name, notset)))
280 del dic[name]
281
282 def setenv(self, name: str, value: str, prepend: Optional[str] = None) -> None:
283 """Set environment variable ``name`` to ``value``.

Callers 3

delenvMethod · 0.95
test_delitemFunction · 0.95
test_cwd_changedMethod · 0.80

Calls 2

appendMethod · 0.80
getMethod · 0.45

Tested by 2

test_delitemFunction · 0.76
test_cwd_changedMethod · 0.64