~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: Vincent Ladeuil
  • Date: 2009-11-03 09:32:17 UTC
  • mto: (4784.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4785.
  • Revision ID: v.ladeuil+lp@free.fr-20091103093217-sodpsi6fzb36vk9y
Hooks daughter classes should always call the base constructor

* bzrlib/tests/test_hooks.py:
(TestHookRegistry.test_items_are_reasonable_keys): Reproduce bug
#389648 and ensures we won't regress again.

* bzrlib/version_info_formats/format_rio.py:
(RioVersionInfoBuilderHooks.__init__): Call base constructor.

* bzrlib/info.py:
(InfoHooks.__init__): Call base constructor.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for the core Hooks logic."""
18
18
 
19
 
from bzrlib import branch, errors
 
19
from bzrlib import (
 
20
    branch,
 
21
    errors,
 
22
    tests,
 
23
    )
20
24
from bzrlib.hooks import (
21
25
    HookPoint,
22
26
    Hooks,
24
28
    known_hooks_key_to_object,
25
29
    known_hooks_key_to_parent_and_attribute,
26
30
    )
27
 
from bzrlib.errors import (
28
 
    UnknownHook,
29
 
    )
30
 
 
31
 
from bzrlib.tests import TestCase
32
 
 
33
 
 
34
 
class TestHooks(TestCase):
 
31
 
 
32
 
 
33
class TestHooks(tests.TestCase):
35
34
 
36
35
    def test_create_hook_first(self):
37
36
        hooks = Hooks()
95
94
 
96
95
    def test_install_named_hook_raises_unknown_hook(self):
97
96
        hooks = Hooks()
98
 
        self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly',
 
97
        self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly',
99
98
                          None, "")
100
99
 
101
100
    def test_install_named_hook_appends_known_hook(self):
111
110
        self.assertEqual("demo", hooks.get_hook_name(None))
112
111
 
113
112
 
114
 
class TestHook(TestCase):
 
113
class TestHook(tests.TestCase):
115
114
 
116
115
    def test___init__(self):
117
116
        doc = ("Invoked after changing the tip of a branch object. Called with"
154
153
            callback_repr, repr(hook))
155
154
 
156
155
 
157
 
class TestHookRegistry(TestCase):
 
156
class TestHookRegistry(tests.TestCase):
158
157
 
159
158
    def test_items_are_reasonable_keys(self):
160
159
        # All the items in the known_hooks registry need to map from
170
169
            new_hooks = factory()
171
170
            self.assertIsInstance(obj, Hooks)
172
171
            self.assertEqual(type(obj), type(new_hooks))
 
172
            self.assertEqual("No hook name", new_hooks.get_hook_name(None))
173
173
 
174
174
    def test_known_hooks_key_to_object(self):
175
175
        self.assertIs(branch.Branch.hooks,