summaryrefslogtreecommitdiffstats
path: root/lang/python/python-cached-property/test.sh
blob: db3606ea1137d971ca4cef66ccf962a3e06fe03c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[ "$1" = python3-cached-property ] || exit 0

python3 - << 'EOF'
from cached_property import cached_property

class MyClass:
    def __init__(self):
        self._calls = 0

    @cached_property
    def value(self):
        self._calls += 1
        return 42

obj = MyClass()
assert obj.value == 42
assert obj.value == 42
assert obj._calls == 1, f"Expected 1 call, got {obj._calls}"
print("python3-cached-property OK")
EOF