~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Robert Collins
  • Date: 2006-01-05 22:30:59 UTC
  • mto: (1534.1.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1536.
  • Revision ID: robertc@robertcollins.net-20060105223059-a8b64f7b47cf12fb
 * bzrlib.osutils.safe_unicode now exists to provide parameter coercion
   for functions that need unicode strings. (Robert Collins)

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(self):
 
72
        self.assertEqual(u'bargam', osutils.safe_unicode(u'bargam'))
 
73
 
 
74
    def test_from_utf8_string(self):
 
75
        self.assertEqual(u'foo\xae', osutils.safe_unicode('foo\xc2\xae'))
 
76
 
 
77
    def test_bad_utf8_string(self):
 
78
        self.assertRaises(BzrBadParameter, osutils.safe_unicode, '\xbb\xbb')