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)
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)
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)
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)