Esempio n. 1
0
    def test_get_content_warning(self):
        """Test requesting content from a non-existent hook."""

        with warnings.catch_warnings(record=True) as warn:
            registry.get_content('doesnotexist', {})
            assert len(warn) == 1
            assert issubclass(warn[-1].category, RuntimeWarning)
Esempio n. 2
0
    def test_get_no_content_warning(self):
        """Test requesting content from an existent hook."""

        registry.register('doesexist')

        with warnings.catch_warnings(record=True) as warn:
            registry.get_content('doesexist', {})
            assert len(warn) == 0
Esempio n. 3
0
    def test_implicit_registration(self):
        """Register a hook implicitly."""

        mycontext = {}
        result = u"I am Dave! Yognaught."

        def _myhook(sender, **kwargs):
            context = kwargs.get('context')
            assert id(mycontext) == id(context)
            kwargs['content'].append(result)

        registry.connect('myhook', _myhook)
        self.assertEquals(result, registry.get_content('myhook', mycontext))