~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-11-11 02:39:42 UTC
  • mfrom: (3825.2.3 hook)
  • Revision ID: pqm@pqm.ubuntu.com-20081111023942-ir0du8iel76giykh
(Jelmer) Add simple commit message template hook.

Show diffs side-by-side

added added

removed removed

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