~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

  • Committer: Vincent Ladeuil
  • Date: 2016-02-01 16:50:54 UTC
  • mto: (6614.2.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6615.
  • Revision ID: v.ladeuil+lp@free.fr-20160201165054-ihgm2jt16ire1sye
Fix assert_ being deprecated by using assertTrue.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2014 Canonical Ltd
 
1
# Copyright (C) 2005-2012, 2014, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
116
116
            ## "expected no-nl, got %r" % lines[5]
117
117
 
118
118
    def check_patch(self, lines):
119
 
        self.assert_(len(lines) > 1)
 
119
        self.assertTrue(len(lines) > 1)
120
120
            ## "Not enough lines for a file header for patch:\n%s" % "".join(lines)
121
 
        self.assert_(lines[0].startswith ('---'))
 
121
        self.assertTrue(lines[0].startswith ('---'))
122
122
            ## 'No orig line for patch:\n%s' % "".join(lines)
123
 
        self.assert_(lines[1].startswith ('+++'))
 
123
        self.assertTrue(lines[1].startswith ('+++'))
124
124
            ## 'No mod line for patch:\n%s' % "".join(lines)
125
 
        self.assert_(len(lines) > 2)
 
125
        self.assertTrue(len(lines) > 2)
126
126
            ## "No hunks for patch:\n%s" % "".join(lines)
127
 
        self.assert_(lines[2].startswith('@@'))
 
127
        self.assertTrue(lines[2].startswith('@@'))
128
128
            ## "No hunk header for patch:\n%s" % "".join(lines)
129
 
        self.assert_('@@' in lines[2][2:])
 
129
        self.assertTrue('@@' in lines[2][2:])
130
130
            ## "Unterminated hunk header for patch:\n%s" % "".join(lines)
131
131
 
132
132
    def test_binary_lines(self):
1500
1500
                                    None, None, None)
1501
1501
        for _, scenario in EncodingAdapter.encoding_scenarios:
1502
1502
            encoding = scenario['encoding']
1503
 
            dirname  = scenario['info']['directory']
 
1503
            dirname = scenario['info']['directory']
1504
1504
            filename = scenario['info']['filename']
1505
1505
 
1506
1506
            self.overrideAttr(diffobj, '_fenc', lambda: encoding)
1507
1507
            relpath = dirname + u'/' + filename
1508
1508
            fullpath = diffobj._safe_filename('safe', relpath)
1509
 
            self.assertEqual(
1510
 
                    fullpath,
1511
 
                    fullpath.encode(encoding).decode(encoding)
1512
 
                    )
1513
 
            self.assert_(fullpath.startswith(diffobj._root + '/safe'))
 
1509
            self.assertEqual(fullpath,
 
1510
                             fullpath.encode(encoding).decode(encoding))
 
1511
            self.assertTrue(fullpath.startswith(diffobj._root + '/safe'))
1514
1512
 
1515
1513
    def test_unencodable_filename(self):
1516
1514
        diffobj = diff.DiffFromTool(['dummy', '@old_path', '@new_path'],
1517
1515
                                    None, None, None)
1518
1516
        for _, scenario in EncodingAdapter.encoding_scenarios:
1519
1517
            encoding = scenario['encoding']
1520
 
            dirname  = scenario['info']['directory']
 
1518
            dirname = scenario['info']['directory']
1521
1519
            filename = scenario['info']['filename']
1522
1520
 
1523
1521
            if encoding == 'iso-8859-1':
1528
1526
            self.overrideAttr(diffobj, '_fenc', lambda: encoding)
1529
1527
            relpath = dirname + u'/' + filename
1530
1528
            fullpath = diffobj._safe_filename('safe', relpath)
1531
 
            self.assertEqual(
1532
 
                    fullpath,
1533
 
                    fullpath.encode(encoding).decode(encoding)
1534
 
                    )
1535
 
            self.assert_(fullpath.startswith(diffobj._root + '/safe'))
 
1529
            self.assertEqual(fullpath,
 
1530
                             fullpath.encode(encoding).decode(encoding))
 
1531
            self.assertTrue(fullpath.startswith(diffobj._root + '/safe'))
1536
1532
 
1537
1533
 
1538
1534
class TestGetTreesAndBranchesToDiffLocked(tests.TestCaseWithTransport):