예제 #1
0
 def test_call_args(self):
     a = dispatch.Dispatch()
     a.add(self.add)
     self.assertEqual(a.call(self.add.__name__, (1, 2)), 3)
     self.assertEqual(self.count, 1)
예제 #2
0
 def test_add_with_name(self):
     a = dispatch.Dispatch()
     a.add(self.func, "somebogusname")
     self.assertEqual(len(a.functions), 1)
     self.assertTrue(self.func in a.functions.values())
     self.assertTrue("somebogusname" in a.functions.keys())
예제 #3
0
 def test_call_noargs(self):
     a = dispatch.Dispatch()
     a.add(self.func)
     a.call(self.func.__name__, ())
     self.assertEqual(self.count, 1)
예제 #4
0
 def test_add_noname(self):
     a = dispatch.Dispatch()
     a.add(self.func)
     self.assertEqual(len(a.functions), 1)
     self.assertTrue(self.func in a.functions.values())
     self.assertTrue(self.func.__name__ in a.functions.keys())