457
457
self.failUnlessEqual('work/MixedCaseParent/nochild', actual)
460
class Test_CICPCanonicalRelpath(tests.TestCaseWithTransport):
462
def assertRelpath(self, expected, base, path):
463
actual = osutils._cicp_canonical_relpath(base, path)
464
self.assertEqual(expected, actual)
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')
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')
481
def test_at_root_slash(self):
482
# We can't test this on Windows, because it has a 'MIN_ABS_PATHLENGTH'
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')
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'
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')
460
503
class TestPumpFile(tests.TestCase):
461
504
"""Test pumpfile method."""