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

Function test_cached_property

testing/test_compat.py:194–211  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192
193
194def test_cached_property() -> None:
195 ncalls = 0
196
197 class Class:
198 @cached_property
199 def prop(self) -> int:
200 nonlocal ncalls
201 ncalls += 1
202 return ncalls
203
204 c1 = Class()
205 assert ncalls == 0
206 assert c1.prop == 1
207 assert c1.prop == 1
208 c2 = Class()
209 assert ncalls == 1
210 assert c2.prop == 2
211 assert c1.prop == 1
212
213
214def test_assert_never_union() -> None:

Callers

nothing calls this directly

Calls 1

ClassClass · 0.70

Tested by

no test coverage detected