~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

  • Committer: Jelmer Vernooij
  • Date: 2011-03-30 13:03:08 UTC
  • mto: This revision was merged to the branch mainline in revision 5747.
  • Revision ID: jelmer@samba.org-20110330130308-ff2a1e6gfwey7mou
Catch deprecation warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        doc = ("Invoked after changing the tip of a branch object. Called with"
44
44
            "a bzrlib.branch.PostChangeBranchTipParams object")
45
45
        hook = HookPoint("post_tip_change", doc, (0, 15), None)
46
 
        hooks.create_hook(hook)
 
46
        self.applyDeprecated(deprecated_in((2, 4)), hooks.create_hook, hook)
47
47
        self.assertEqual(hook, hooks['post_tip_change'])
48
48
 
49
49
    def test_create_hook_name_collision_errors(self):
52
52
            "a bzrlib.branch.PostChangeBranchTipParams object")
53
53
        hook = HookPoint("post_tip_change", doc, (0, 15), None)
54
54
        hook2 = HookPoint("post_tip_change", None, None, None)
55
 
        hooks.create_hook(hook)
56
 
        self.assertRaises(errors.DuplicateKey, hooks.create_hook, hook2)
 
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)
57
58
        self.assertEqual(hook, hooks['post_tip_change'])
58
59
 
59
60
    def test_docs(self):
62
63
            pass
63
64
        hooks = MyHooks("bzrlib.tests.test_hooks", "some_hooks")
64
65
        hooks['legacy'] = []
65
 
        hook1 = HookPoint('post_tip_change',
 
66
        hooks.add_hook('post_tip_change',
66
67
            "Invoked after the tip of a branch changes. Called with "
67
 
            "a ChangeBranchTipParams object.", (1, 4), None)
68
 
        hook2 = HookPoint('pre_tip_change',
 
68
            "a ChangeBranchTipParams object.", (1, 4))
 
69
        hooks.add_hook('pre_tip_change',
69
70
            "Invoked before the tip of a branch changes. Called with "
70
71
            "a ChangeBranchTipParams object. Hooks should raise "
71
72
            "TipChangeRejected to signal that a tip change is not permitted.",
72
73
            (1, 6), None)
73
 
        hooks.create_hook(hook1)
74
 
        hooks.create_hook(hook2)
75
74
        self.assertEqualDiff(
76
75
            "MyHooks\n"
77
76
            "-------\n"