/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/blackbox/test_diff.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-06 01:18:08 UTC
  • mfrom: (7143 work)
  • mto: This revision was merged to the branch mainline in revision 7151.
  • Revision ID: jelmer@jelmer.uk-20181106011808-y870f4vq0ork3ahu
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
        out, err = self.run_bzr(cmd, retcode=1)
185
185
        self.assertEqual('', err)
186
186
        self.assertEqual("=== modified file 'file'\n"
187
 
                          "--- old/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
188
 
                          "+++ new/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
189
 
                          "@@ -1,1 +1,1 @@\n"
190
 
                          "-new content\n"
191
 
                          "+contents of branch1/file\n"
192
 
                          "\n", subst_dates(out))
 
187
                         "--- old/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
 
188
                         "+++ new/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
 
189
                         "@@ -1,1 +1,1 @@\n"
 
190
                         "-new content\n"
 
191
                         "+contents of branch1/file\n"
 
192
                         "\n", subst_dates(out))
193
193
 
194
194
    def check_b1_vs_b2(self, cmd):
195
195
        # Compare branch1 vs branch2 using cmd and check the result
196
196
        out, err = self.run_bzr(cmd, retcode=1)
197
197
        self.assertEqual('', err)
198
198
        self.assertEqualDiff("=== modified file 'file'\n"
199
 
                              "--- old/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
200
 
                              "+++ new/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
201
 
                              "@@ -1,1 +1,1 @@\n"
202
 
                              "-contents of branch1/file\n"
203
 
                              "+new content\n"
204
 
                              "\n", subst_dates(out))
 
199
                             "--- old/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
 
200
                             "+++ new/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
 
201
                             "@@ -1,1 +1,1 @@\n"
 
202
                             "-contents of branch1/file\n"
 
203
                             "+new content\n"
 
204
                             "\n", subst_dates(out))
205
205
 
206
206
    def check_no_diffs(self, cmd):
207
207
        # Check that running cmd returns an empty diff
261
261
                                retcode=1)
262
262
        self.assertEqual('', err)
263
263
        self.assertEqualDiff("=== modified file 'file'\n"
264
 
                              "--- old/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
265
 
                              "+++ new/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
266
 
                              "@@ -1,1 +1,1 @@\n"
267
 
                              "-new content\n"
268
 
                              "+contents of branch1/file\n"
269
 
                              "\n", subst_dates(out))
 
264
                             "--- old/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
 
265
                             "+++ new/file\tYYYY-MM-DD HH:MM:SS +ZZZZ\n"
 
266
                             "@@ -1,1 +1,1 @@\n"
 
267
                             "-new content\n"
 
268
                             "+contents of branch1/file\n"
 
269
                             "\n", subst_dates(out))
270
270
 
271
271
    def example_branch2(self):
272
272
        branch1_tree = self.make_branch_and_tree('branch1')
392
392
            'diff -Oprogress_bar=none -r 1 --diff-options -ub',
393
393
            universal_newlines=True,
394
394
            retcode=None)
395
 
        if 'Diff is not installed on this machine' in err:
 
395
        if b'Diff is not installed on this machine' in err:
396
396
            raise tests.TestSkipped("No external 'diff' is available")
397
 
        self.assertEqual('', err)
 
397
        self.assertEqual(b'', err)
398
398
        # We have to skip the stuff in the middle, because it depends
399
399
        # on time.time()
400
400
        self.assertStartsWith(
401
401
            out,
402
 
            "=== added file 'goodbye'\n"
403
 
            "--- old/goodbye\t1970-01-01 00:00:00 +0000\n"
404
 
            "+++ new/goodbye\t")
405
 
        self.assertEndsWith(out, "\n@@ -0,0 +1 @@\n"
406
 
                                 "+baz\n\n")
 
402
            b"=== added file 'goodbye'\n"
 
403
            b"--- old/goodbye\t1970-01-01 00:00:00 +0000\n"
 
404
            b"+++ new/goodbye\t")
 
405
        self.assertEndsWith(out, b"\n@@ -0,0 +1 @@\n"
 
406
                                 b"+baz\n\n")
407
407
 
408
408
    def test_external_diff_options_and_using(self):
409
409
        """Test that the options are passed correctly to an external diff process"""
423
423
        self.make_example_branch()
424
424
        self.build_tree_contents([('hello', b'hello world!\n')])
425
425
        output = self.run_bzr_subprocess('diff', retcode=1)[0]
426
 
        self.assertTrue('\n+hello world!\n' in output)
 
426
        self.assertTrue(b'\n+hello world!\n' in output)