~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_msgeditor.py

msgeditor and bzr info improvements (olaf)

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
    def test__get_editor(self):
54
54
        # Test that _get_editor can return a decent list of items
55
55
        bzr_editor = os.environ.get('BZR_EDITOR')
 
56
        visual = os.environ.get('VISUAL')
56
57
        editor = os.environ.get('EDITOR')
57
58
        try:
58
59
            os.environ['BZR_EDITOR'] = 'bzr_editor'
 
60
            os.environ['VISUAL'] = 'visual'
59
61
            os.environ['EDITOR'] = 'editor'
60
62
 
61
63
            ensure_config_dir_exists()
65
67
 
66
68
            editors = list(_get_editor())
67
69
 
68
 
            self.assertEqual(['bzr_editor', 'config_editor', 'editor'],
69
 
                editors[:3])
 
70
            self.assertEqual(['bzr_editor', 'config_editor', 'visual',
 
71
                              'editor'], editors[:4])
70
72
 
71
73
            if sys.platform == 'win32':
72
 
                self.assertEqual(['wordpad.exe', 'notepad.exe'], editors[3:])
 
74
                self.assertEqual(['wordpad.exe', 'notepad.exe'], editors[4:])
73
75
            else:
74
 
                self.assertEqual(['vi', 'pico', 'nano', 'joe'], editors[3:])
 
76
                self.assertEqual(['/usr/bin/editor', 'vi', 'pico', 'nano',
 
77
                                  'joe'], editors[4:])
75
78
 
76
79
        finally:
77
80
            # Restore the environment
79
82
                del os.environ['BZR_EDITOR']
80
83
            else:
81
84
                os.environ['BZR_EDITOR'] = bzr_editor
 
85
            if visual is None:
 
86
                del os.environ['VISUAL']
 
87
            else:
 
88
                os.environ['VISUAL'] = visual
82
89
            if editor is None:
83
90
                del os.environ['EDITOR']
84
91
            else:
85
92
                os.environ['EDITOR'] = editor
86