def test_expose(): @expose("increment") class Counter(object): def __init__(self): self.x = 0 def increment(self, amount=1): self.x += amount assert watchable(Counter) assert Counter.__name__ == "Counter" assert isinstance(Counter.increment, MethodSpectator)
def test_subclass_override(): @expose("method") class Parent: def method(self): pass class Child(Parent): def method(self): pass assert watchable(Child) assert isinstance(Child.method, MethodSpectator)
def test_expose_as(): WatchableList = expose_as("WatchableList", list, "append") assert watchable(WatchableList) assert issubclass(WatchableList, list) assert WatchableList.__name__ == "WatchableList" assert isinstance(WatchableList.append, MethodSpectator)
def test_watchable(): assert watchable(Watchable) assert watchable(Watchable())