/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-10 19:59:55 UTC
  • mfrom: (1704 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060510195955-df080afb1daa3a96
[merge] bzr.dev 1704

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import sys
21
21
 
22
22
from bzrlib.branch import Branch
 
23
from bzrlib.config import ensure_config_dir_exists, config_filename
23
24
import bzrlib.msgeditor 
24
25
from bzrlib.tests import TestCaseWithTransport, TestSkipped
25
26
from bzrlib.trace import mutter
62
63
                del os.environ['BZR_EDITOR']
63
64
        super(MsgEditorTest, self).tearDown()
64
65
 
65
 
    def test_get_editor(self):
66
 
        os.environ['BZR_EDITOR'] = 'fed'
67
 
        editors = [i for i in bzrlib.msgeditor._get_editor()]
68
 
        self.assertNotEqual([], editors, 'No editor found')
69
 
        self.assertEqual('fed', editors[0])
70
 
 
71
66
    def test_run_editor(self):
72
67
        if sys.platform == "win32":
73
68
            f = file('fed.bat', 'w')
134
129
 
135
130
        self.assertRaises(IOError, bzrlib.msgeditor.edit_commit_message, '')
136
131
 
 
132
    def test__get_editor(self):
 
133
        # Test that _get_editor can return a decent list of items
 
134
        bzr_editor = os.environ.get('BZR_EDITOR')
 
135
        editor = os.environ.get('EDITOR')
 
136
        try:
 
137
            os.environ['BZR_EDITOR'] = 'bzr_editor'
 
138
            os.environ['EDITOR'] = 'editor'
 
139
 
 
140
            ensure_config_dir_exists()
 
141
            f = open(config_filename(), 'wb')
 
142
            f.write('editor = config_editor\n')
 
143
            f.close()
 
144
 
 
145
            editors = list(bzrlib.msgeditor._get_editor())
 
146
 
 
147
            self.assertEqual(['bzr_editor', 'config_editor', 'editor'],
 
148
                editors[:3])
 
149
 
 
150
            if sys.platform == 'win32':
 
151
                self.assertEqual(['wordpad.exe', 'notepad.exe'], editors[3:])
 
152
            else:
 
153
                self.assertEqual(['vi', 'pico', 'nano', 'joe'], editors[3:])
 
154
 
 
155
        finally:
 
156
            # Restore the environment
 
157
            if bzr_editor is None:
 
158
                del os.environ['BZR_EDITOR']
 
159
            else:
 
160
                os.environ['BZR_EDITOR'] = bzr_editor
 
161
            if editor is None:
 
162
                del os.environ['EDITOR']
 
163
            else:
 
164
                os.environ['EDITOR'] = editor
 
165