~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    errors,
27
27
    msgeditor,
28
28
    osutils,
29
 
    tests,
30
29
    trace,
31
30
    )
32
31
from bzrlib.msgeditor import (
34
33
    edit_commit_message_encoded
35
34
)
36
35
from bzrlib.tests import (
 
36
    features,
37
37
    TestCaseInTempDir,
38
38
    TestCaseWithTransport,
39
39
    TestNotApplicable,
80
80
""")
81
81
 
82
82
    def make_multiple_pending_tree(self):
83
 
        from bzrlib import config
84
 
        config.GlobalConfig().set_user_option('email',
85
 
                                              'Bilbo Baggins <bb@hobbit.net>')
 
83
        config.GlobalStack().set('email', 'Bilbo Baggins <bb@hobbit.net>')
86
84
        tree = self.make_branch_and_tree('a')
87
85
        tree.commit('Initial checkin.', timestamp=1230912900, timezone=0)
88
86
        tree2 = tree.bzrdir.clone('b').open_workingtree()
251
249
        self.overrideEnv('VISUAL', 'visual')
252
250
        self.overrideEnv('EDITOR', 'editor')
253
251
 
254
 
        conf = config.GlobalConfig.from_string('editor = config_editor\n',
255
 
                                               save=True)
256
 
 
 
252
        conf = config.GlobalStack()
 
253
        conf.store._load_from_string('[DEFAULT]\neditor = config_editor\n')
 
254
        conf.store.save()
257
255
        editors = list(msgeditor._get_editor())
258
256
        editors = [editor for (editor, cfg_src) in editors]
259
257
 
309
307
        self.assertFileEqual(expected, msgfilename)
310
308
 
311
309
    def test__create_temp_file_with_commit_template_in_unicode_dir(self):
312
 
        self.requireFeature(tests.UnicodeFilenameFeature)
 
310
        self.requireFeature(features.UnicodeFilenameFeature)
313
311
        if hasattr(self, 'info'):
314
312
            tmpdir = self.info['directory']
315
313
            os.mkdir(tmpdir)
344
342
        self.assertRaises(errors.BadCommitMessageEncoding,
345
343
                          msgeditor.edit_commit_message, '')
346
344
 
 
345
    def test_set_commit_message_no_hooks(self):
 
346
        commit_obj = commit.Commit()
 
347
        self.assertIs(None,
 
348
            msgeditor.set_commit_message(commit_obj))
 
349
 
 
350
    def test_set_commit_message_hook(self):
 
351
        msgeditor.hooks.install_named_hook("set_commit_message",
 
352
                lambda commit_obj, existing_message: "save me some typing\n", None)
 
353
        commit_obj = commit.Commit()
 
354
        self.assertEquals("save me some typing\n",
 
355
            msgeditor.set_commit_message(commit_obj))
 
356
 
347
357
    def test_generate_commit_message_template_no_hooks(self):
348
358
        commit_obj = commit.Commit()
349
359
        self.assertIs(None,
368
378
        ERROR_BAD_EXE_FORMAT = 193
369
379
        file("textfile.txt", "w").close()
370
380
        e = self.assertRaises(WindowsError, subprocess.call, "textfile.txt")
371
 
        # Python2.4 used the 'winerror' as the errno, which confuses a lot of
372
 
        # our error trapping code. Make sure that we understand the mapping
373
 
        # correctly.
374
 
        if sys.version_info >= (2, 5):
375
 
            self.assertEqual(e.errno, errno.ENOEXEC)
376
 
            self.assertEqual(e.winerror, ERROR_BAD_EXE_FORMAT)
377
 
        else:
378
 
            self.assertEqual(e.errno, ERROR_BAD_EXE_FORMAT)
 
381
        self.assertEqual(e.errno, errno.ENOEXEC)
 
382
        self.assertEqual(e.winerror, ERROR_BAD_EXE_FORMAT)