/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: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

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