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

Method setdefault

src/_pytest/stash.py:94–101  ·  src/_pytest/stash.py::Stash.setdefault

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

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

Callers 12

test_stashFunction · 0.95
set_levelMethod · 0.80
warn_explicit_forFunction · 0.80
_add_statsMethod · 0.80
summary_warningsMethod · 0.80
_folded_skipsFunction · 0.80
parametrizeMethod · 0.80
_register_fixtureMethod · 0.80
_addexcinfoMethod · 0.80
newMethod · 0.80
recursionindexMethod · 0.80

Calls

no outgoing calls

Tested by 2

test_stashFunction · 0.76
_addexcinfoMethod · 0.64