~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

  • Committer: Martin Pool
  • Date: 2009-03-03 03:01:49 UTC
  • mfrom: (4070 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4073.
  • Revision ID: mbp@sourcefrog.net-20090303030149-8p8o8hszdtqa7w8f
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
 
28
28
class TestUrlToPath(TestCase):
29
 
    
 
29
 
30
30
    def test_basename(self):
31
31
        # bzrlib.urlutils.basename
32
32
        # Test bzrlib.urlutils.split()
83
83
        try:
84
84
            u'uni/\xb5'.encode(osutils.get_user_encoding())
85
85
        except UnicodeError:
86
 
            # locale cannot handle unicode 
 
86
            # locale cannot handle unicode
87
87
            pass
88
88
        else:
89
89
            norm_file('uni/%C2%B5', u'uni/\xb5')
226
226
        test('file:///bar/foo', 'file:///bar/', 'foo')
227
227
        test('http://host/foo', 'http://host/', 'foo')
228
228
        test('http://host/', 'http://host', '')
229
 
        
 
229
 
230
230
        # Invalid joinings
231
231
        # Cannot go above root
232
232
        # Implicitly at root:
264
264
 
265
265
        # Test joining to a path with a trailing slash
266
266
        test('foo/bar', 'foo/', 'bar')
267
 
        
 
267
 
268
268
        # Invalid joinings
269
269
        # Cannot go above root
270
270
        self.assertRaises(InvalidURLJoin, urlutils.joinpath, '/', '../baz')
315
315
        #     to_url('C:/path/to/foo '))
316
316
        self.assertEqual('file:///C:/path/to/f%20oo',
317
317
            to_url('C:/path/to/f oo'))
318
 
        
 
318
 
319
319
        self.assertEqual('file:///', to_url('/'))
320
320
 
321
321
        try:
513
513
        def test(expected, base, other):
514
514
            result = urlutils.relative_url(base, other)
515
515
            self.assertEqual(expected, result)
516
 
            
 
516
 
517
517
        test('a', 'http://host/', 'http://host/a')
518
518
        test('http://entirely/different', 'sftp://host/branch',
519
519
                    'http://entirely/different')
528
528
                    'sftp://host/home/jelmer/branch/2b')
529
529
        test('../../branch/feature/%2b', 'http://host/home/jelmer/bar/%2b',
530
530
                    'http://host/home/jelmer/branch/feature/%2b')
531
 
        test('../../branch/feature/2b', 'http://host/home/jelmer/bar/2b/', 
 
531
        test('../../branch/feature/2b', 'http://host/home/jelmer/bar/2b/',
532
532
                    'http://host/home/jelmer/branch/feature/2b')
533
533
        # relative_url should preserve a trailing slash
534
534
        test('../../branch/feature/2b/', 'http://host/home/jelmer/bar/2b/',
592
592
 
593
593
        os.chdir(u'dod\xe9')
594
594
 
595
 
        # On Mac OSX this directory is actually: 
 
595
        # On Mac OSX this directory is actually:
596
596
        #   u'/dode\u0301' => '/dode\xcc\x81
597
 
        # but we should normalize it back to 
 
597
        # but we should normalize it back to
598
598
        #   u'/dod\xe9' => '/dod\xc3\xa9'
599
599
        url = urlutils.local_path_to_url('.')
600
600
        self.assertEndsWith(url, '/dod%C3%A9')