class Till(object): def __init__(self, menu, order_klass=Order, receipt_klass=Receipt): self._menu = menu self._order_klass = order_klass self._current_order = self._order_klass() self._receipt_klass = receipt_klass def_delegator('_current_order', 'view_order') def ring_up(self, item, quantity): self._menu.verify_in_menu(item) self._current_order.ring_up(item, quantity) def receipt_as_json(self): receipt = self._receipt_klass(self._current_order.view_order(), self._menu.view_menu()) return receipt.receipt_as_json()
def test_called_in_non_class_scope(self): with self.assertRaises(NotCalledInClassScope): def_delegator("what", "ever")
class Foo(object): def_delegator("bar.baz", "qoox")
class Foo(object): def_delegator("bar", "baz")
class Foo(object): def_delegator("s", "__len__") def __init__(self): self.s = set()
class Foo(object): def_delegator("dct", "keys") dct = {'key': 42}