~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-17 21:17:22 UTC
  • mto: This revision was merged to the branch mainline in revision 2298.
  • Revision ID: john@arbash-meinel.com-20070217211722-yxx3xjxtxeijc8d7
Add safe_file_id as a helper in osutils.

Show diffs side-by-side

added added

removed removed

Lines of Context:
302
302
    def test_bad_utf8_string(self):
303
303
        # This check may eventually go away
304
304
        self.assertRaises(BzrBadParameterNotUnicode,
305
 
                          osutils.safe_utf8, '\xbb\xbb')
 
305
                          osutils.safe_revision_id, '\xbb\xbb')
306
306
 
307
307
    def test_none(self):
308
308
        """Currently, None is a valid revision_id"""
309
309
        self.assertEqual(None, osutils.safe_revision_id(None))
310
310
 
311
311
 
 
312
class TestSafeFileId(TestCase):
 
313
 
 
314
    def test_from_ascii_string(self):
 
315
        f = 'foobar'
 
316
        self.assertEqual('foobar', osutils.safe_file_id(f))
 
317
 
 
318
    def test_from_unicode_string_ascii_contents(self):
 
319
        self.assertEqual('bargam', osutils.safe_file_id(u'bargam'))
 
320
 
 
321
    def test_from_unicode_string_unicode_contents(self):
 
322
        self.assertEqual('bargam\xc2\xae',
 
323
                         osutils.safe_file_id(u'bargam\xae'))
 
324
 
 
325
    def test_from_utf8_string(self):
 
326
        self.assertEqual('foo\xc2\xae',
 
327
                         osutils.safe_file_id('foo\xc2\xae'))
 
328
 
 
329
    def test_bad_utf8_string(self):
 
330
        # This check may eventually go away
 
331
        self.assertRaises(BzrBadParameterNotUnicode,
 
332
                          osutils.safe_file_id, '\xbb\xbb')
 
333
 
 
334
    def test_none(self):
 
335
        """Currently, None is a valid revision_id"""
 
336
        self.assertEqual(None, osutils.safe_file_id(None))
 
337
 
 
338
 
312
339
class TestWin32Funcs(TestCase):
313
340
    """Test that the _win32 versions of os utilities return appropriate paths."""
314
341