()
| 192 | |
| 193 | |
| 194 | def 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 | |
| 214 | def test_assert_never_union() -> None: |