~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_diff.py

(vila) Do not show exception to user on pointless commit error. (Jonathan
 Riddell)

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    transform,
34
34
    )
35
35
from bzrlib.symbol_versioning import deprecated_in
36
 
from bzrlib.tests import features, EncodingAdapter
 
36
from bzrlib.tests import features
37
37
from bzrlib.tests.blackbox.test_diff import subst_dates
38
38
 
39
39
 
1421
1421
        diff_obj._prepare_files('file2-id', 'oldname2', 'newname2')
1422
1422
 
1423
1423
 
1424
 
class TestDiffFromToolEncodedFilename(tests.TestCaseWithTransport):
1425
 
 
1426
 
    def test_encodable_filename(self):
1427
 
        # Just checks file path for external diff tool.
1428
 
        # We cannot change CPython's internal encoding used by os.exec*.
1429
 
        import sys
1430
 
        diffobj = diff.DiffFromTool(['dummy', '@old_path', '@new_path'],
1431
 
                                    None, None, None)
1432
 
        for _, scenario in EncodingAdapter.encoding_scenarios:
1433
 
            encoding = scenario['encoding']
1434
 
            dirname  = scenario['info']['directory']
1435
 
            filename = scenario['info']['filename']
1436
 
 
1437
 
            self.overrideAttr(diffobj, '_fenc', lambda: encoding)
1438
 
            relpath = dirname + u'/' + filename
1439
 
            fullpath = diffobj._safe_filename('safe', relpath)
1440
 
            self.assertEqual(
1441
 
                    fullpath,
1442
 
                    fullpath.encode(encoding).decode(encoding)
1443
 
                    )
1444
 
            self.assert_(fullpath.startswith(diffobj._root + '/safe'))
1445
 
 
1446
 
    def test_unencodable_filename(self):
1447
 
        import sys
1448
 
        diffobj = diff.DiffFromTool(['dummy', '@old_path', '@new_path'],
1449
 
                                    None, None, None)
1450
 
        for _, scenario in EncodingAdapter.encoding_scenarios:
1451
 
            encoding = scenario['encoding']
1452
 
            dirname  = scenario['info']['directory']
1453
 
            filename = scenario['info']['filename']
1454
 
 
1455
 
            if encoding == 'iso-8859-1':
1456
 
                encoding = 'iso-8859-2'
1457
 
            else:
1458
 
                encoding = 'iso-8859-1'
1459
 
 
1460
 
            self.overrideAttr(diffobj, '_fenc', lambda: encoding)
1461
 
            relpath = dirname + u'/' + filename
1462
 
            fullpath = diffobj._safe_filename('safe', relpath)
1463
 
            self.assertEqual(
1464
 
                    fullpath,
1465
 
                    fullpath.encode(encoding).decode(encoding)
1466
 
                    )
1467
 
            self.assert_(fullpath.startswith(diffobj._root + '/safe'))
1468
 
 
1469
 
 
1470
1424
class TestGetTreesAndBranchesToDiffLocked(tests.TestCaseWithTransport):
1471
1425
 
1472
1426
    def call_gtabtd(self, path_list, revision_specs, old_url, new_url):