~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_mergetools.py

  • Committer: Patch Queue Manager
  • Date: 2016-01-31 13:36:59 UTC
  • mfrom: (6613.1.5 1538480-match-hostname)
  • Revision ID: pqm@pqm.ubuntu.com-20160131133659-ouy92ee2wlv9xz8m
(vila) Use ssl.match_hostname instead of our own. (Vincent Ladeuil)

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
19
18
import sys
20
19
import tempfile
21
20
 
23
22
    mergetools,
24
23
    tests
25
24
)
26
 
from bzrlib.tests.features import backslashdir_feature
27
25
 
28
26
 
29
27
class TestFilenameSubstitution(tests.TestCaseInTempDir):
39
37
             '-o',
40
38
             'test.txt'],
41
39
            args)
42
 
        
 
40
 
43
41
    def test_spaces(self):
44
42
        cmd_list = ['kdiff3', '{base}', '{this}', '{other}', '-o', '{result}']
45
43
        args, tmpfile = mergetools._subst_filename(cmd_list,
71
69
                         'test.txt.OTHER'))
72
70
        cmd_list = ['some_tool', '{this_temp}']
73
71
        args, tmpfile = mergetools._subst_filename(cmd_list, 'test.txt')
74
 
        self.failUnlessExists(tmpfile)
 
72
        self.assertPathExists(tmpfile)
75
73
        os.remove(tmpfile)
76
74
 
77
75
 
81
79
        self.assertTrue(mergetools.check_availability(sys.executable))
82
80
 
83
81
    def test_exe_on_path(self):
84
 
        self.assertTrue(mergetools.check_availability(
85
 
            os.path.basename(sys.executable)))
 
82
        self.assertTrue(mergetools.check_availability('python'))
86
83
 
87
84
    def test_nonexistent(self):
88
85
        self.assertFalse(mergetools.check_availability('DOES NOT EXIST'))
108
105
            ('test.txt.THIS', 'this stuff'),
109
106
            ('test.txt.OTHER', 'other stuff'),
110
107
        ))
111
 
        
 
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
 
112
122
    def test_success(self):
113
123
        def dummy_invoker(exe, args, cleanup):
114
124
            self._exe = exe
119
129
        self.assertEqual(0, retcode)
120
130
        self.assertEqual('tool', self._exe)
121
131
        self.assertEqual(['test.txt'], self._args)
122
 
    
 
132
 
123
133
    def test_failure(self):
124
134
        def dummy_invoker(exe, args, cleanup):
125
135
            self._exe = exe
135
145
        def dummy_invoker(exe, args, cleanup):
136
146
            self._exe = exe
137
147
            self._args = args
138
 
            self.failUnlessExists(args[0])
 
148
            self.assertPathExists(args[0])
139
149
            f = open(args[0], 'wt')
140
150
            f.write('temp stuff')
141
151
            f.close()
145
155
                                    dummy_invoker)
146
156
        self.assertEqual(0, retcode)
147
157
        self.assertEqual('tool', self._exe)
148
 
        self.failIfExists(self._args[0])
 
158
        self.assertPathDoesNotExist(self._args[0])
149
159
        self.assertFileEqual('temp stuff', 'test.txt')
150
 
    
 
160
 
151
161
    def test_failure_tempfile(self):
152
162
        def dummy_invoker(exe, args, cleanup):
153
163
            self._exe = exe
154
164
            self._args = args
155
 
            self.failUnlessExists(args[0])
 
165
            self.assertPathExists(args[0])
156
166
            self.log(repr(args))
157
167
            f = open(args[0], 'wt')
158
168
            self.log(repr(f))