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

Method get

src/_pytest/cacheprovider.py:187–204  ·  src/_pytest/cacheprovider.py::Cache.get

Return the cached value for the given key. If no value was yet cached or the value cannot be read, the specified default is returned. :param key: Must be a ``/`` separated value. Usually the first name is the name of your plugin or your application.

(self, key: str, default)

Source from the content-addressed store, hash-verified

185 return self._cachedir.joinpath(self._CACHE_PREFIX_VALUES, Path(key))
186
187 def get(self, key: str, default):
188 class="st">"""Return the cached value for the given key.
189
190 If no value was yet cached or the value cannot be read, the specified
191 default is returned.
192
193 :param key:
194 Must be a ``/`` separated value. Usually the first
195 name is the name of your plugin or your application.
196 :param default:
197 The value to return in case of a cache-miss or invalid cache value.
198 class="st">"""
199 path = self._getvaluepath(key)
200 try:
201 with path.open(class="st">"r", encoding=class="st">"UTF-8") as f:
202 return json.load(f)
203 except (ValueError, OSError):
204 return default
205
206 def set(self, key: str, value: object) -> None:
207 class="st">"""Save value for the given key.

Callers 4

__init__Method · 0.45
pytest_sessionfinishMethod · 0.45
__init__Method · 0.45
cacheshowFunction · 0.45

Calls 3

_getvaluepathMethod · 0.95
openMethod · 0.80
loadMethod · 0.45

Tested by

no test coverage detected