Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
    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)
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
 def test_iteration(self):
     function_set = FunctionSet(self.functions)
     for function in function_set:
         self.assertIn(function, self.functions)
Esempio n. 8
0
 def test_len(self):
     function_set = FunctionSet(self.functions)
     self.assertEqual(len(function_set), 3)