/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: Jelmer Vernooij
  • Date: 2011-01-20 20:30:14 UTC
  • mto: (5622.4.1 uninstall-hook)
  • mto: This revision was merged to the branch mainline in revision 5669.
  • Revision ID: jelmer@samba.org-20110120203014-sn88wcb24cpq0d4r
Some work on lazy hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.hooks import (
25
25
    HookPoint,
26
26
    Hooks,
 
27
    install_lazy_named_hook,
27
28
    known_hooks,
28
29
    known_hooks_key_to_object,
29
30
    known_hooks_key_to_parent_and_attribute,
 
31
    _lazy_hooks,
30
32
    )
31
33
from bzrlib.symbol_versioning import (
32
34
    deprecated_in,
112
114
        hooks.install_named_hook('set_rh', None, "demo")
113
115
        self.assertEqual("demo", hooks.get_hook_name(None))
114
116
 
 
117
    hooks = Hooks()
 
118
 
 
119
    def test_install_lazy_named_hook(self):
 
120
        # When the hook points are not yet registered the hook is
 
121
        # added to the _lazy_hooks dictionary in bzrlib.hooks.
 
122
        self.hooks['set_rh'] = []
 
123
        set_rh = lambda: None
 
124
        install_lazy_named_hook('bzrlib.tests.test_hooks',
 
125
            'TestHooks.hooks', 'set_rh', set_rh, "demo")
 
126
        self.assertEquals([(set_rh, "demo")],
 
127
            _lazy_hooks[
 
128
                ('bzrlib.tests.test_hooks', 'TestHooks.hooks', 'set_rh')])
 
129
        self.assertEqual("demo", self.hooks.get_hook_name(set_rh))
 
130
 
115
131
 
116
132
class TestHook(tests.TestCase):
117
133