~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Martin Pool
  • Date: 2006-01-06 01:13:05 UTC
  • mfrom: (1534.1.4 integration)
  • Revision ID: mbp@sourcefrog.net-20060106011305-3772285d84b5cbb4
[merge] robertc

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import sys
22
22
 
23
23
import bzrlib
 
24
from bzrlib.errors import BzrBadParameter
24
25
import bzrlib.osutils as osutils
25
 
from bzrlib.tests import TestCaseInTempDir
 
26
from bzrlib.tests import TestCaseInTempDir, TestCase
26
27
 
27
28
 
28
29
class TestOSUtils(TestCaseInTempDir):
61
62
 
62
63
    # TODO: test fancy_rename using a MemoryTransport
63
64
 
 
65
 
 
66
class TestSafeUnicode(TestCase):
 
67
 
 
68
    def test_from_ascii_string(self):
 
69
        self.assertEqual(u'foobar', osutils.safe_unicode('foobar'))
 
70
 
 
71
    def test_from_unicode_string_ascii_contents(self):
 
72
        self.assertEqual(u'bargam', osutils.safe_unicode(u'bargam'))
 
73
 
 
74
    def test_from_unicode_string_unicode_contents(self):
 
75
        self.assertEqual(u'bargam\xae', osutils.safe_unicode(u'bargam\xae'))
 
76
 
 
77
    def test_from_utf8_string(self):
 
78
        self.assertEqual(u'foo\xae', osutils.safe_unicode('foo\xc2\xae'))
 
79
 
 
80
    def test_bad_utf8_string(self):
 
81
        self.assertRaises(BzrBadParameter, osutils.safe_unicode, '\xbb\xbb')