def test_add(self): function_set = FunctionSet(self.functions) def function4(): return 'function4' function_set.add(function4) self.assertIn(function4, function_set) self.assertEqual(len(function_set), 4) function_set.add(self.functions[1]) self.assertIn(self.functions[1], function_set) self.assertEqual(len(function_set), 4)
def test_contains(self): function_set = FunctionSet(self.functions) # check contains with a function object self.assertIn(self.functions[0], function_set) self.assertIn(self.functions[1], function_set) self.assertIn(self.functions[2], function_set) # check contains with a code object self.assertIn(self.functions[0].func_code, function_set) self.assertIn(self.functions[1].func_code, function_set) self.assertIn(self.functions[2].func_code, function_set)
def __init__(self, *arguments, **keywords): """ Initialize the monitoring class. Parameters ---------- *arguments : list The list of arguments required by the base monitor. They will be passed on the super class of the mixing **keywords : dict Dictionary of keyword arguments. The `functions` keyword if defined should be a list of function or method objects inside which recording will take place. """ functions = keywords.pop('functions', ()) super(FocusedLineMixin, self).__init__(*arguments, **keywords) self.functions = FunctionSet(functions)
def test_discard(self): function_set = FunctionSet(self.functions) function_set.discard(self.functions[1]) self.assertNotIn(self.functions[1], function_set) self.assertEqual(len(function_set), 2)
def test_iteration(self): function_set = FunctionSet(self.functions) for function in function_set: self.assertIn(function, self.functions)
def test_len(self): function_set = FunctionSet(self.functions) self.assertEqual(len(function_set), 3)