~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_mergetools.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-30 18:28:17 UTC
  • mfrom: (5967.10.2 test-cat)
  • Revision ID: pqm@pqm.ubuntu.com-20110630182817-83a5q9r9rxfkdn8r
(mbp) don't use subprocesses for testing cat (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import os
 
18
import re
18
19
import sys
19
20
import tempfile
20
21
 
22
23
    mergetools,
23
24
    tests
24
25
)
 
26
from bzrlib.tests.features import backslashdir_feature
25
27
 
26
28
 
27
29
class TestFilenameSubstitution(tests.TestCaseInTempDir):
37
39
             '-o',
38
40
             'test.txt'],
39
41
            args)
40
 
 
 
42
        
41
43
    def test_spaces(self):
42
44
        cmd_list = ['kdiff3', '{base}', '{this}', '{other}', '-o', '{result}']
43
45
        args, tmpfile = mergetools._subst_filename(cmd_list,
79
81
        self.assertTrue(mergetools.check_availability(sys.executable))
80
82
 
81
83
    def test_exe_on_path(self):
82
 
        self.assertTrue(mergetools.check_availability('python'))
 
84
        self.assertTrue(mergetools.check_availability(
 
85
            os.path.basename(sys.executable)))
83
86
 
84
87
    def test_nonexistent(self):
85
88
        self.assertFalse(mergetools.check_availability('DOES NOT EXIST'))
105
108
            ('test.txt.THIS', 'this stuff'),
106
109
            ('test.txt.OTHER', 'other stuff'),
107
110
        ))
108
 
 
109
 
    def test_invoke_expands_exe_path(self):
110
 
        self.overrideEnv('PATH', os.path.dirname(sys.executable))
111
 
        def dummy_invoker(exe, args, cleanup):
112
 
            self._exe = exe
113
 
            self._args = args
114
 
            cleanup(0)
115
 
            return 0
116
 
        command = '%s {result}' % os.path.basename(sys.executable)
117
 
        retcode = mergetools.invoke(command, 'test.txt', dummy_invoker)
118
 
        self.assertEqual(0, retcode)
119
 
        self.assertEqual(sys.executable, self._exe)
120
 
        self.assertEqual(['test.txt'], self._args)
121
 
 
 
111
        
122
112
    def test_success(self):
123
113
        def dummy_invoker(exe, args, cleanup):
124
114
            self._exe = exe
129
119
        self.assertEqual(0, retcode)
130
120
        self.assertEqual('tool', self._exe)
131
121
        self.assertEqual(['test.txt'], self._args)
132
 
 
 
122
    
133
123
    def test_failure(self):
134
124
        def dummy_invoker(exe, args, cleanup):
135
125
            self._exe = exe
157
147
        self.assertEqual('tool', self._exe)
158
148
        self.assertPathDoesNotExist(self._args[0])
159
149
        self.assertFileEqual('temp stuff', 'test.txt')
160
 
 
 
150
    
161
151
    def test_failure_tempfile(self):
162
152
        def dummy_invoker(exe, args, cleanup):
163
153
            self._exe = exe