예제 #1
0
 def test_run_multiple(self):
     obj = Object()
     cbargs = []
     def callback(*args):
         cbargs.append(args)
     for i in range(5):
         add_callback(obj, callback, (obj,))
     run_callbacks(obj)
     self.assertEqual(cbargs, [(obj,)]*5)
예제 #2
0
 def test_run_one(self):
     obj = Object()
     cbargs = []
     def callback(*args):
         cbargs.append(args)
     add_callback(obj, callback, (obj,))
     run_callbacks(obj)
     self.assertEqual(cbargs, [(obj,)])
     self.assertIsNone(obj._callbacks)
예제 #3
0
    def test_run_one(self):
        obj = Object()
        cbargs = []

        def callback(*args):
            cbargs.append(args)

        add_callback(obj, callback, (obj, ))
        run_callbacks(obj)
        self.assertEqual(cbargs, [(obj, )])
        self.assertIsNone(obj._callbacks)
예제 #4
0
    def test_run_multiple(self):
        obj = Object()
        cbargs = []

        def callback(*args):
            cbargs.append(args)

        for i in range(5):
            add_callback(obj, callback, (obj, ))
        run_callbacks(obj, n=2)
        self.assertEqual(cbargs, [(obj, )] * 2)
        run_callbacks(obj)
        self.assertEqual(cbargs, [(obj, )] * 5)