249
class TestSafeUtf8(TestCase):
251
def test_from_ascii_string(self):
253
self.assertEqual('foobar', osutils.safe_utf8(f))
255
def test_from_unicode_string_ascii_contents(self):
256
self.assertEqual('bargam', osutils.safe_utf8(u'bargam'))
258
def test_from_unicode_string_unicode_contents(self):
259
self.assertEqual('bargam\xc2\xae', osutils.safe_utf8(u'bargam\xae'))
261
def test_from_utf8_string(self):
262
self.assertEqual('foo\xc2\xae', osutils.safe_utf8('foo\xc2\xae'))
264
def test_bad_utf8_string(self):
265
self.assertRaises(BzrBadParameterNotUnicode,
266
osutils.safe_utf8, '\xbb\xbb')
269
class TestSafeRevisionId(TestCase):
271
def test_from_ascii_string(self):
273
self.assertEqual('foobar', osutils.safe_revision_id(f))
274
self.assertIs(osutils.safe_utf8(f), f)
276
def test_from_unicode_string_ascii_contents(self):
277
self.assertEqual('bargam', osutils.safe_revision_id(u'bargam'))
279
def test_from_unicode_string_unicode_contents(self):
280
self.assertEqual('bargam\xc2\xae',
281
osutils.safe_revision_id(u'bargam\xae'))
283
def test_from_utf8_string(self):
284
self.assertEqual('foo\xc2\xae',
285
osutils.safe_revision_id('foo\xc2\xae'))
287
def test_bad_utf8_string(self):
288
# This check may eventually go away
289
self.assertRaises(BzrBadParameterNotUnicode,
290
osutils.safe_utf8, '\xbb\xbb')
293
"""Currently, None is a valid revision_id"""
294
self.assertEqual(None, osutils.safe_revision_id(None))
297
249
class TestWin32Funcs(TestCase):
298
250
"""Test that the _win32 versions of os utilities return appropriate paths."""