/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 breezy/tests/test_mergetools.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
    def test_spaces_and_quotes(self):
55
55
        cmd_list = ['kdiff3', '{base}', '{this}', '{other}', '-o', '{result}']
56
 
        args, tmpfile = mergetools._subst_filename(
57
 
            cmd_list, 'file with "space and quotes".txt')
 
56
        args, tmpfile = mergetools._subst_filename(cmd_list,
 
57
            'file with "space and quotes".txt')
58
58
        self.assertEqual(
59
59
            ['kdiff3',
60
60
             'file with "space and quotes".txt.BASE',
78
78
    def test_full_path(self):
79
79
        self.assertTrue(mergetools.check_availability(sys.executable))
80
80
 
 
81
    def test_exe_on_path(self):
 
82
        self.assertTrue(mergetools.check_availability('python'))
 
83
 
81
84
    def test_nonexistent(self):
82
85
        self.assertFalse(mergetools.check_availability('DOES NOT EXIST'))
83
86
 
97
100
        self._exe = None
98
101
        self._args = None
99
102
        self.build_tree_contents((
100
 
            ('test.txt', b'stuff'),
101
 
            ('test.txt.BASE', b'base stuff'),
102
 
            ('test.txt.THIS', b'this stuff'),
103
 
            ('test.txt.OTHER', b'other stuff'),
 
103
            ('test.txt', 'stuff'),
 
104
            ('test.txt.BASE', 'base stuff'),
 
105
            ('test.txt.THIS', 'this stuff'),
 
106
            ('test.txt.OTHER', 'other stuff'),
104
107
        ))
105
108
 
106
109
    def test_invoke_expands_exe_path(self):
107
110
        self.overrideEnv('PATH', os.path.dirname(sys.executable))
108
 
 
109
111
        def dummy_invoker(exe, args, cleanup):
110
112
            self._exe = exe
111
113
            self._args = args
144
146
            self._exe = exe
145
147
            self._args = args
146
148
            self.assertPathExists(args[0])
147
 
            with open(args[0], 'wt') as f:
148
 
                f.write('temp stuff')
 
149
            f = open(args[0], 'wt')
 
150
            f.write('temp stuff')
 
151
            f.close()
149
152
            cleanup(0)
150
153
            return 0
151
154
        retcode = mergetools.invoke('tool {this_temp}', 'test.txt',
153
156
        self.assertEqual(0, retcode)
154
157
        self.assertEqual('tool', self._exe)
155
158
        self.assertPathDoesNotExist(self._args[0])
156
 
        self.assertFileEqual(b'temp stuff', 'test.txt')
 
159
        self.assertFileEqual('temp stuff', 'test.txt')
157
160
 
158
161
    def test_failure_tempfile(self):
159
162
        def dummy_invoker(exe, args, cleanup):
161
164
            self._args = args
162
165
            self.assertPathExists(args[0])
163
166
            self.log(repr(args))
164
 
            with open(args[0], 'wt') as f:
165
 
                self.log(repr(f))
166
 
                f.write('temp stuff')
 
167
            f = open(args[0], 'wt')
 
168
            self.log(repr(f))
 
169
            f.write('temp stuff')
 
170
            f.close()
167
171
            cleanup(1)
168
172
            return 1
169
173
        retcode = mergetools.invoke('tool {this_temp}', 'test.txt',
170
174
                                    dummy_invoker)
171
175
        self.assertEqual(1, retcode)
172
176
        self.assertEqual('tool', self._exe)
173
 
        self.assertFileEqual(b'stuff', 'test.txt')
 
177
        self.assertFileEqual('stuff', 'test.txt')