~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_urlutils.py

  • Committer: Wouter van Heyst
  • Date: 2006-06-07 12:22:54 UTC
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: larstiq@larstiq.dyndns.org-20060607122254-c617eeabfd5e05e7
more tests handle LANG=C

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import bzrlib
23
23
from bzrlib.errors import InvalidURL, InvalidURLJoin
24
24
import bzrlib.urlutils as urlutils
25
 
from bzrlib.tests import TestCaseInTempDir, TestCase
 
25
from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped
26
26
 
27
27
 
28
28
class TestUrlToPath(TestCase):
79
79
        norm_file('path/to/foo', '../path/to/foo')
80
80
 
81
81
        # Local paths are assumed to *not* be escaped at all
82
 
        norm_file('uni/%C2%B5', u'uni/\xb5')
 
82
        try:
 
83
            u'uni/\xb5'.encode(bzrlib.user_encoding)
 
84
        except UnicodeError:
 
85
            # locale cannot handle unicode 
 
86
            pass
 
87
        else:
 
88
            norm_file('uni/%C2%B5', u'uni/\xb5')
 
89
 
83
90
        norm_file('uni/%25C2%25B5', u'uni/%C2%B5')
84
91
        norm_file('uni/%20b', u'uni/ b')
85
92
        # All the crazy characters get escaped in local paths => file:/// urls
219
226
        to_url = urlutils._posix_local_path_to_url
220
227
        self.assertEqual('file:///path/to/foo',
221
228
            to_url('/path/to/foo'))
222
 
        self.assertEqual('file:///path/to/r%C3%A4ksm%C3%B6rg%C3%A5s',
223
 
            to_url(u'/path/to/r\xe4ksm\xf6rg\xe5s'))
 
229
 
 
230
        try:
 
231
            result = to_url(u'/path/to/r\xe4ksm\xf6rg\xe5s')
 
232
        except UnicodeError:
 
233
            raise TestSkipped("local encoding cannot handle unicode")
 
234
 
 
235
        self.assertEqual('file:///path/to/r%C3%A4ksm%C3%B6rg%C3%A5s', result)
224
236
 
225
237
    def test_posix_local_path_from_url(self):
226
238
        from_url = urlutils._posix_local_path_from_url
237
249
        to_url = urlutils._win32_local_path_to_url
238
250
        self.assertEqual('file:///C|/path/to/foo',
239
251
            to_url('C:/path/to/foo'))
240
 
        self.assertEqual('file:///D|/path/to/r%C3%A4ksm%C3%B6rg%C3%A5s',
241
 
            to_url(u'd:/path/to/r\xe4ksm\xf6rg\xe5s'))
 
252
 
 
253
        try:
 
254
            result = to_url(u'd:/path/to/r\xe4ksm\xf6rg\xe5s')
 
255
        except UnicodeError:
 
256
            raise TestSkipped("local encoding cannot handle unicode")
 
257
 
 
258
        self.assertEqual('file:///D|/path/to/r%C3%A4ksm%C3%B6rg%C3%A5s', result)
242
259
 
243
260
    def test_win32_local_path_from_url(self):
244
261
        from_url = urlutils._win32_local_path_from_url