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

Method get

src/_pytest/cacheprovider.py:146–163  ·  view source on GitHub ↗

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

144 return self._cachedir.joinpath(self._CACHE_PREFIX_VALUES, Path(key))
145
146 def get(self, key: str, default):
147 """Return the cached value for the given key.
148
149 If no value was yet cached or the value cannot be read, the specified
150 default is returned.
151
152 :param key:
153 Must be a ``/`` separated value. Usually the first
154 name is the name of your plugin or your application.
155 :param default:
156 The value to return in case of a cache-miss or invalid cache value.
157 """
158 path = self._getvaluepath(key)
159 try:
160 with path.open("r") as f:
161 return json.load(f)
162 except (ValueError, OSError):
163 return default
164
165 def set(self, key: str, value: object) -> None:
166 """Save value for the given key.

Callers 4

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

Calls 2

_getvaluepathMethod · 0.95
loadMethod · 0.45

Tested by

no test coverage detected