有谁知道一个模拟或存根框架,它允许存根属性甚至像这个装饰器那样的类属性?
class classproperty:
"""
Decorator to read-only static properties
"""
def __init__(self, getter):
self.getter = getter
def __get__(self, instance, owner):
return self.getter(owner)
class Foo:
_name = "Name"
@classproperty
def foo(cls):
return cls._name
我目前正在使用mockito,但这不允许对属性进行存根。