Пример #1
0
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()
Пример #2
0
 def test_called_in_non_class_scope(self):
     with self.assertRaises(NotCalledInClassScope):
         def_delegator("what", "ever")
Пример #3
0
 class Foo(object):
     def_delegator("bar.baz", "qoox")
Пример #4
0
 class Foo(object):
     def_delegator("bar", "baz")
Пример #5
0
        class Foo(object):
            def_delegator("s", "__len__")

            def __init__(self):
                self.s = set()
Пример #6
0
 def test_called_in_non_class_scope(self):
     with self.assertRaises(NotCalledInClassScope):
         def_delegator("what", "ever")
Пример #7
0
 class Foo(object):
     def_delegator("dct", "keys")
     dct = {'key': 42}