Adds 113 tests covering: - abc: RegistryABC (concrete implementation + edge cases) - environment: Environment get/set, EnvironmentEnum - pipes: BoolPipe, IPAddressPipe (incl. roundtrip + error cases) - time: Cron (next(), intervals, invalid expression) - utils: Cache (TTL, expiry, cleanup), get_value (incl. bug documentation: cast result not returned for string->typed values), JSONProcessor (nested objects, enums, defaults) - property: classproperty (class access, instance access, subclass) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
36 lines
606 B
Python
36 lines
606 B
Python
from cpl.core.property import classproperty
|
|
|
|
|
|
class MyClass:
|
|
_value = 42
|
|
|
|
@classproperty
|
|
def value(cls):
|
|
return cls._value
|
|
|
|
@classproperty
|
|
def name(cls):
|
|
return cls.__name__
|
|
|
|
|
|
class Child(MyClass):
|
|
_value = 99
|
|
|
|
|
|
def test_classproperty_on_class():
|
|
assert MyClass.value == 42
|
|
|
|
|
|
def test_classproperty_on_instance():
|
|
obj = MyClass()
|
|
assert obj.value == 42
|
|
|
|
|
|
def test_classproperty_subclass_inherits_override():
|
|
assert Child.value == 99
|
|
|
|
|
|
def test_classproperty_returns_class_name():
|
|
assert MyClass.name == "MyClass"
|
|
assert Child.name == "Child"
|