Beispiel #1
0
    def test_cache_app_with_actions_and_global_actions(self):
        class A:
            @action
            def x(self):
                pass

            @action
            def y(self):
                pass

            def z(self):
                pass

        def z():
            pass

        self.entry.cache_app_class(A, self.clspath)
        self.entry.cache_functions([(z, self.action_tag)], self.clspath)
        self.assertEqual(self.entry.main, A)

        self.assert_entry_has_functions({
            'A.x':
            FunctionEntry(run=A.x, is_bound=True, tags=self.action_tag),
            'A.y':
            FunctionEntry(run=A.y, is_bound=True, tags=self.action_tag),
            'z':
            FunctionEntry(run=z, is_bound=False, tags=self.action_tag)
        })
Beispiel #2
0
    def test_cache_action_multiple_actions(self):
        def x(): pass

        def y(): pass

        self.entry.cache_functions([(x, self.action_tag), (y, self.action_tag)], self.clspath)
        self.assert_entry_has_functions({'x': FunctionEntry(run=x, is_bound=False, tags=self.action_tag),
                                         'y': FunctionEntry(run=y, is_bound=False, tags=self.action_tag)})
Beispiel #3
0
    def test_clear_existing_bound_functions_no_bound_actions(self):
        def x(): pass

        def y(): pass

        self.entry.cache_functions([(x, self.action_tag), (y, self.action_tag)], self.clspath)
        self.entry.clear_bound_functions()
        self.assert_entry_has_functions({'x': FunctionEntry(run=x, is_bound=False, tags=self.action_tag),
                                         'y': FunctionEntry(run=y, is_bound=False, tags=self.action_tag)})
Beispiel #4
0
    def test_cache_action_overwrite(self):
        def x(): pass

        original_id = id(x)
        self.entry.cache_functions([(x, self.action_tag)], self.clspath)

        def x(): pass

        self.entry.cache_functions([(x, self.action_tag)], self.clspath)
        self.assert_entry_has_functions({'x': FunctionEntry(run=x, is_bound=False, tags=self.action_tag)})
        self.assertNotEqual(id(self.entry.functions['x'].run), original_id)
Beispiel #5
0
    def test_clear_existing_bound_functions(self):
        class A:
            @action
            def x(self): pass

            @action
            def y(self): pass

            def z(self): pass

        def z(): pass

        self.entry.cache_app_class(A, self.clspath)
        self.entry.cache_functions([(z, self.action_tag)], self.clspath)
        self.entry.clear_bound_functions()
        self.assert_entry_has_functions({'z': FunctionEntry(run=z, is_bound=False, tags=self.action_tag)})