~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-10-13 06:08:53 UTC
  • mfrom: (4737.1.1 merge-2.0-into-devel)
  • Revision ID: pqm@pqm.ubuntu.com-20091013060853-erk2aaj80fnkrv25
(andrew) Merge lp:bzr/2.0 into lp:bzr, including fixes for #322807,
        #389413, #402623 and documentation improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
457
457
        self.failUnlessEqual('work/MixedCaseParent/nochild', actual)
458
458
 
459
459
 
 
460
class Test_CICPCanonicalRelpath(tests.TestCaseWithTransport):
 
461
 
 
462
    def assertRelpath(self, expected, base, path):
 
463
        actual = osutils._cicp_canonical_relpath(base, path)
 
464
        self.assertEqual(expected, actual)
 
465
 
 
466
    def test_simple(self):
 
467
        self.build_tree(['MixedCaseName'])
 
468
        base = osutils.realpath(self.get_transport('.').local_abspath('.'))
 
469
        self.assertRelpath('MixedCaseName', base, 'mixedcAsename')
 
470
 
 
471
    def test_subdir_missing_tail(self):
 
472
        self.build_tree(['MixedCaseParent/', 'MixedCaseParent/a_child'])
 
473
        base = osutils.realpath(self.get_transport('.').local_abspath('.'))
 
474
        self.assertRelpath('MixedCaseParent/a_child', base,
 
475
                           'MixedCaseParent/a_child')
 
476
        self.assertRelpath('MixedCaseParent/a_child', base,
 
477
                           'MixedCaseParent/A_Child')
 
478
        self.assertRelpath('MixedCaseParent/not_child', base,
 
479
                           'MixedCaseParent/not_child')
 
480
 
 
481
    def test_at_root_slash(self):
 
482
        # We can't test this on Windows, because it has a 'MIN_ABS_PATHLENGTH'
 
483
        # check...
 
484
        if osutils.MIN_ABS_PATHLENGTH > 1:
 
485
            raise tests.TestSkipped('relpath requires %d chars'
 
486
                                    % osutils.MIN_ABS_PATHLENGTH)
 
487
        self.assertRelpath('foo', '/', '/foo')
 
488
 
 
489
    def test_at_root_drive(self):
 
490
        if sys.platform != 'win32':
 
491
            raise tests.TestNotApplicable('we can only test drive-letter relative'
 
492
                                          ' paths on Windows where we have drive'
 
493
                                          ' letters.')
 
494
        # see bug #322807
 
495
        # The specific issue is that when at the root of a drive, 'abspath'
 
496
        # returns "C:/" or just "/". However, the code assumes that abspath
 
497
        # always returns something like "C:/foo" or "/foo" (no trailing slash).
 
498
        self.assertRelpath('foo', 'C:/', 'C:/foo')
 
499
        self.assertRelpath('foo', 'X:/', 'X:/foo')
 
500
        self.assertRelpath('foo', 'X:/', 'X://foo')
 
501
 
 
502
 
460
503
class TestPumpFile(tests.TestCase):
461
504
    """Test pumpfile method."""
462
505