~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: Patch Queue Manager
  • Date: 2015-12-17 18:39:00 UTC
  • mfrom: (6606.1.2 fix-float)
  • Revision ID: pqm@pqm.ubuntu.com-20151217183900-0719du2uv1kwu3lc
(vila) Inline testtools private method to fix an issue in xenial (the
 private implementation has changed in an backward incompatible way).
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    install_lazy_named_hook,
30
30
    known_hooks,
31
31
    known_hooks_key_to_object,
32
 
    known_hooks_key_to_parent_and_attribute,
33
32
    )
34
33
from bzrlib.symbol_versioning import (
35
34
    deprecated_in,
38
37
 
39
38
class TestHooks(tests.TestCase):
40
39
 
41
 
    def test_create_hook_first(self):
42
 
        hooks = Hooks("bzrlib.tests.test_hooks", "some_hooks")
43
 
        doc = ("Invoked after changing the tip of a branch object. Called with"
44
 
            "a bzrlib.branch.PostChangeBranchTipParams object")
45
 
        hook = HookPoint("post_tip_change", doc, (0, 15), None)
46
 
        self.applyDeprecated(deprecated_in((2, 4)), hooks.create_hook, hook)
47
 
        self.assertEqual(hook, hooks['post_tip_change'])
48
 
 
49
 
    def test_create_hook_name_collision_errors(self):
50
 
        hooks = Hooks("bzrlib.tests.test_hooks", "some_hooks")
51
 
        doc = ("Invoked after changing the tip of a branch object. Called with"
52
 
            "a bzrlib.branch.PostChangeBranchTipParams object")
53
 
        hook = HookPoint("post_tip_change", doc, (0, 15), None)
54
 
        hook2 = HookPoint("post_tip_change", None, None, None)
55
 
        self.applyDeprecated(deprecated_in((2, 4)), hooks.create_hook, hook)
56
 
        self.assertRaises(errors.DuplicateKey, self.applyDeprecated,
57
 
            deprecated_in((2, 4, 0)), hooks.create_hook, hook2)
58
 
        self.assertEqual(hook, hooks['post_tip_change'])
59
 
 
60
40
    def test_docs(self):
61
41
        """docs() should return something reasonable about the Hooks."""
62
42
        class MyHooks(Hooks):
286
266
        self.assertIs(branch.Branch.hooks,
287
267
            known_hooks_key_to_object(('bzrlib.branch', 'Branch.hooks')))
288
268
 
289
 
    def test_known_hooks_key_to_parent_and_attribute_deprecated(self):
290
 
        self.assertEqual((branch.Branch, 'hooks'),
291
 
            self.applyDeprecated(deprecated_in((2,3)),
292
 
                known_hooks_key_to_parent_and_attribute,
293
 
                ('bzrlib.branch', 'Branch.hooks')))
294
 
        self.assertEqual((branch, 'Branch'),
295
 
            self.applyDeprecated(deprecated_in((2,3)),
296
 
                known_hooks_key_to_parent_and_attribute,
297
 
                ('bzrlib.branch', 'Branch')))
298
 
 
299
269
    def test_known_hooks_key_to_parent_and_attribute(self):
300
270
        self.assertEqual((branch.Branch, 'hooks'),
301
271
            known_hooks.key_to_parent_and_attribute(