~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
 
4
# it under the terms of the GNU General Public License version 2 as published by
 
5
# the Free Software Foundation.
7
6
#
8
7
# This program is distributed in the hope that it will be useful,
9
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
57
56
        self._bzr_editor = os.environ.get('BZR_EDITOR', None)
58
57
 
59
58
    def tearDown(self):
60
 
        if self._bzr_editor is not None:
 
59
        if self._bzr_editor != None:
61
60
            os.environ['BZR_EDITOR'] = self._bzr_editor
62
61
        else:
63
 
            if os.environ.get('BZR_EDITOR', None) is not None:
 
62
            if os.environ.get('BZR_EDITOR', None) != None:
64
63
                del os.environ['BZR_EDITOR']
65
64
        super(MsgEditorTest, self).tearDown()
66
65
 
80
79
        self.assertEqual(True, bzrlib.msgeditor._run_editor(''),
81
80
                         'Unable to run dummy fake editor')
82
81
 
83
 
    def make_fake_editor(self):
84
 
        """Set up environment so that an editor will be a known script.
85
 
 
86
 
        Sets up BZR_EDITOR so that if an editor is spawned it will run a
87
 
        script that just adds a known message to the start of the file.
88
 
        """
 
82
    def test_edit_commit_message(self):
 
83
        working_tree = self.make_uncommitted_tree()
 
84
        # make fake editor
89
85
        f = file('fed.py', 'wb')
90
86
        f.write('#!%s\n' % sys.executable)
91
87
        f.write("""\
115
111
            os.chmod('fed.py', 0755)
116
112
            os.environ['BZR_EDITOR'] = './fed.py'
117
113
 
118
 
    def test_edit_commit_message(self):
119
 
        working_tree = self.make_uncommitted_tree()
120
 
        self.make_fake_editor()
121
 
 
122
114
        mutter('edit_commit_message without infotext')
123
115
        self.assertEqual('test message from fed\n',
124
116
                         bzrlib.msgeditor.edit_commit_message(''))
127
119
        self.assertEqual('test message from fed\n',
128
120
                         bzrlib.msgeditor.edit_commit_message(u'\u1234'))
129
121
 
130
 
    def test_start_message(self):
131
 
        self.make_uncommitted_tree()
132
 
        self.make_fake_editor()
133
 
        self.assertEqual('test message from fed\nstart message\n',
134
 
                         bzrlib.msgeditor.edit_commit_message('',
135
 
                                              start_message='start message\n'))
136
 
        self.assertEqual('test message from fed\n',
137
 
                         bzrlib.msgeditor.edit_commit_message('',
138
 
                                              start_message=''))
139
 
 
140
122
    def test_deleted_commit_message(self):
141
123
        working_tree = self.make_uncommitted_tree()
142
124