~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

Merge bzr.dev.

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 test_edit_commit_message(self):
84
 
        working_tree = self.make_uncommitted_tree()
85
 
        # make fake editor
 
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
        """
86
89
        f = file('fed.py', 'wb')
87
90
        f.write('#!%s\n' % sys.executable)
88
91
        f.write("""\
112
115
            os.chmod('fed.py', 0755)
113
116
            os.environ['BZR_EDITOR'] = './fed.py'
114
117
 
 
118
    def test_edit_commit_message(self):
 
119
        working_tree = self.make_uncommitted_tree()
 
120
        self.make_fake_editor()
 
121
 
115
122
        mutter('edit_commit_message without infotext')
116
123
        self.assertEqual('test message from fed\n',
117
124
                         bzrlib.msgeditor.edit_commit_message(''))
120
127
        self.assertEqual('test message from fed\n',
121
128
                         bzrlib.msgeditor.edit_commit_message(u'\u1234'))
122
129
 
 
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
 
123
140
    def test_deleted_commit_message(self):
124
141
        working_tree = self.make_uncommitted_tree()
125
142