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

Method setdefault

src/_pytest/stash.py:90–97  ·  view source on GitHub ↗

Return the value of key if already set, otherwise set the value of key to default and return default.

(self, key: StashKey[T], default: T)

Source from the content-addressed store, hash-verified

88 return default
89
90 def setdefault(self, key: StashKey[T], default: T) -> T:
91 """Return the value of key if already set, otherwise set the value
92 of key to default and return default."""
93 try:
94 return self[key]
95 except KeyError:
96 self[key] = default
97 return default
98
99 def __delitem__(self, key: StashKey[T]) -> None:
100 """Delete the value for key.

Callers 10

test_stashFunction · 0.95
set_levelMethod · 0.80
_add_statsMethod · 0.80
summary_warningsMethod · 0.80
_folded_skipsFunction · 0.80
parsefactoriesMethod · 0.80
_addexcinfoMethod · 0.80
recursionindexMethod · 0.80
parse_hookimpl_optsMethod · 0.80

Calls

no outgoing calls

Tested by 2

test_stashFunction · 0.76
_addexcinfoMethod · 0.64