~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

  • Committer: Jelmer Vernooij
  • Date: 2008-08-21 16:58:21 UTC
  • mto: (3825.2.1 hook)
  • mto: This revision was merged to the branch mainline in revision 3828.
  • Revision ID: jelmer@samba.org-20080821165821-r5vaoznc96k0kd18
Add tests for commit_message_template hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
import bzrlib
24
24
from bzrlib import (
 
25
    commit,
25
26
    errors,
26
27
    msgeditor,
27
28
    osutils,
292
293
                              msgeditor.edit_commit_message, '')
293
294
        finally:
294
295
            osutils.set_or_unset_env('LANG', old_env)
 
296
 
 
297
    def test_generate_commit_message_template_no_hooks(self):
 
298
        commit_obj = commit.Commit()
 
299
        self.assertIs(None, 
 
300
            msgeditor.generate_commit_message_template(commit_obj))
 
301
 
 
302
    def test_generate_commit_message_template_hook(self):
 
303
        def restoreDefaults():
 
304
            msgeditor.hooks['commit_message_template'] = []
 
305
        self.addCleanup(restoreDefaults)
 
306
        msgeditor.hooks.install_named_hook("commit_message_template",
 
307
                lambda commit_obj, msg: "save me some typing\n", None)
 
308
        commit_obj = commit.Commit()
 
309
        self.assertEquals("save me some typing\n", 
 
310
            msgeditor.generate_commit_message_template(commit_obj))