~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

  • Committer: Martin Pool
  • Date: 2011-02-07 01:30:38 UTC
  • mto: This revision was merged to the branch mainline in revision 5650.
  • Revision ID: mbp@canonical.com-20110207013038-kbm3fx0pemehjnk2
Use cmdline.split on BZR_EDITOR so that you can pass names including spaces.

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):
 
144
    def make_do_nothing_editor(self, basename='fed'):
145
145
        if sys.platform == "win32":
146
 
            f = file('fed.bat', 'w')
 
146
            name = basename + '.bat'
 
147
            f = file(name, 'w')
147
148
            f.write('@rem dummy fed')
148
149
            f.close()
149
 
            return 'fed.bat'
 
150
            return name
150
151
        else:
151
 
            f = file('fed.sh', 'wb')
 
152
            name = basename + '.sh'
 
153
            f = file(name, 'wb')
152
154
            f.write('#!/bin/sh\n')
153
155
            f.close()
154
 
            os.chmod('fed.sh', 0755)
155
 
            return './fed.sh'
 
156
            os.chmod(name, 0755)
 
157
            return './' + name
156
158
 
157
159
    def test_run_editor(self):
158
160
        self.overrideEnv('BZR_EDITOR', self.make_do_nothing_editor())
159
161
        self.assertEqual(True, msgeditor._run_editor(''),
160
162
                         'Unable to run dummy fake editor')
161
163
 
 
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
 
162
173
    def make_fake_editor(self, message='test message from fed\\n'):
163
174
        """Set up environment so that an editor will be a known script.
164
175