~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-24 14:12:53 UTC
  • mto: This revision was merged to the branch mainline in revision 2095.
  • Revision ID: john@arbash-meinel.com-20061024141253-783fba812b197b70
(John Arbash Meinel) Update version information for 0.13 development

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
        self.assertEqual(True, bzrlib.msgeditor._run_editor(''),
81
81
                         'Unable to run dummy fake editor')
82
82
 
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
 
        """
 
83
    def test_edit_commit_message(self):
 
84
        working_tree = self.make_uncommitted_tree()
 
85
        # make fake editor
89
86
        f = file('fed.py', 'wb')
90
87
        f.write('#!%s\n' % sys.executable)
91
88
        f.write("""\
115
112
            os.chmod('fed.py', 0755)
116
113
            os.environ['BZR_EDITOR'] = './fed.py'
117
114
 
118
 
    def test_edit_commit_message(self):
119
 
        working_tree = self.make_uncommitted_tree()
120
 
        self.make_fake_editor()
121
 
 
122
115
        mutter('edit_commit_message without infotext')
123
116
        self.assertEqual('test message from fed\n',
124
117
                         bzrlib.msgeditor.edit_commit_message(''))
127
120
        self.assertEqual('test message from fed\n',
128
121
                         bzrlib.msgeditor.edit_commit_message(u'\u1234'))
129
122
 
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
123
    def test_deleted_commit_message(self):
141
124
        working_tree = self.make_uncommitted_tree()
142
125
 
187
170
                del os.environ['EDITOR']
188
171
            else:
189
172
                os.environ['EDITOR'] = editor
190
 
 
191
 
    def test__create_temp_file_with_commit_template(self):
192
 
        # check that commit template written properly
193
 
        # and has platform native line-endings (CRLF on win32)
194
 
        create_file = bzrlib.msgeditor._create_temp_file_with_commit_template
195
 
        msgfilename, hasinfo = create_file('infotext','----','start message')
196
 
        self.assertNotEqual(None, msgfilename)
197
 
        self.assertTrue(hasinfo)
198
 
        expected = os.linesep.join(['start message',
199
 
                                    '',
200
 
                                    '',
201
 
                                    '----',
202
 
                                    '',
203
 
                                    'infotext'])
204
 
        self.assertFileEqual(expected, msgfilename)
205
 
 
206
 
    def test__create_temp_file_with_empty_commit_template(self):
207
 
        # empty file
208
 
        create_file = bzrlib.msgeditor._create_temp_file_with_commit_template
209
 
        msgfilename, hasinfo = create_file('')
210
 
        self.assertNotEqual(None, msgfilename)
211
 
        self.assertFalse(hasinfo)
212
 
        self.assertFileEqual('', msgfilename)