~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-03 18:19:49 UTC
  • mto: This revision was merged to the branch mainline in revision 1851.
  • Revision ID: john@arbash-meinel.com-20060703181949-2a46f438c62e7b53
Add a test that urlutils creates normalized paths

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
import sys
21
21
 
 
22
from bzrlib import osutils, urlutils
22
23
import bzrlib
23
24
from bzrlib.errors import InvalidURL, InvalidURLJoin
24
 
import bzrlib.urlutils as urlutils
25
25
from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped
26
26
 
27
27
 
464
464
        test('http://host/', 'http://host', 'http://host/')
465
465
        #test('.', 'http://host/', 'http://host')
466
466
        test('http://host', 'http://host/', 'http://host')
 
467
 
 
468
 
 
469
class TestCwdToURL(TestCaseInTempDir):
 
470
    """Test that local_path_to_url works base on the cwd"""
 
471
 
 
472
    def test_dot(self):
 
473
        # This test will fail if getcwd is not ascii
 
474
        cwd = osutils.getcwd()
 
475
        try:
 
476
            cwd = cwd.encode('ascii')
 
477
        except UnicodeError:
 
478
            raise TestSkipped('test must be run in an ASCII directory')
 
479
 
 
480
        url = urlutils.local_path_to_url('.')
 
481
        self.assertEndsWith(url, cwd)
 
482
 
 
483
    def test_non_ascii(self):
 
484
        try:
 
485
            os.mkdir(u'dod\xe9')
 
486
        except UnicodeError:
 
487
            raise TestSkipped('cannot create unicode directory')
 
488
 
 
489
        os.chdir(u'dod\xe9')
 
490
 
 
491
        # On Mac OSX this directory is actually: 
 
492
        #   u'/dode\u0301' => '/dode\xcc\x81
 
493
        # but we should normalize it back to 
 
494
        #   u'/dod\xe9' => '/dod\xc3\xa9'
 
495
        url = urlutils.local_path_to_url('.')
 
496
        self.assertEndsWith(url, '/dod%C3%A9')