~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

  • Committer: Gordon Tyler
  • Date: 2011-01-21 23:51:15 UTC
  • mto: This revision was merged to the branch mainline in revision 5632.
  • Revision ID: gordon@doxxx.net-20110121235115-9sdqamejot1h0481
Replace usage of format function from python 2.6 with our own very simple formatting function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
  hell\u00d8
142
142
""".encode('utf8') in template)
143
143
 
144
 
    def make_do_nothing_editor(self, basename='fed'):
 
144
    def make_do_nothing_editor(self):
145
145
        if sys.platform == "win32":
146
 
            name = basename + '.bat'
147
 
            f = file(name, 'w')
 
146
            f = file('fed.bat', 'w')
148
147
            f.write('@rem dummy fed')
149
148
            f.close()
150
 
            return name
 
149
            return 'fed.bat'
151
150
        else:
152
 
            name = basename + '.sh'
153
 
            f = file(name, 'wb')
 
151
            f = file('fed.sh', 'wb')
154
152
            f.write('#!/bin/sh\n')
155
153
            f.close()
156
 
            os.chmod(name, 0755)
157
 
            return './' + name
 
154
            os.chmod('fed.sh', 0755)
 
155
            return './fed.sh'
158
156
 
159
157
    def test_run_editor(self):
160
158
        self.overrideEnv('BZR_EDITOR', self.make_do_nothing_editor())
161
159
        self.assertEqual(True, msgeditor._run_editor(''),
162
160
                         'Unable to run dummy fake editor')
163
161
 
164
 
    def test_parse_editor_name(self):
165
 
        """Correctly interpret names with spaces.
166
 
 
167
 
        See <https://bugs.launchpad.net/bzr/+bug/220331>
168
 
        """
169
 
        self.overrideEnv('BZR_EDITOR',
170
 
            '"%s"' % self.make_do_nothing_editor('name with spaces'))
171
 
        self.assertEqual(True, msgeditor._run_editor('a_filename'))    
172
 
 
173
162
    def make_fake_editor(self, message='test message from fed\\n'):
174
163
        """Set up environment so that an editor will be a known script.
175
164