~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-10-11 09:26:57 UTC
  • mfrom: (1996.3.37 use_lazy_importer)
  • Revision ID: pqm@pqm.ubuntu.com-20061011092657-e42bec6ef14c036c
(John Arbash Meinel) use lazy importing to improve startup time

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import sys
24
24
 
25
25
import bzrlib
 
26
from bzrlib import (
 
27
    errors,
 
28
    osutils,
 
29
    )
26
30
from bzrlib.errors import BzrBadParameterNotUnicode, InvalidURL
27
 
import bzrlib.osutils as osutils
28
31
from bzrlib.tests import (
29
32
        StringIOWrapper,
30
33
        TestCase, 
78
81
        self.assertEqual(type(result), str)
79
82
        self.assertContainsRe(result, r'^[a-z0-9]{100}$')
80
83
 
 
84
    def test_is_inside(self):
 
85
        is_inside = osutils.is_inside
 
86
        self.assertTrue(is_inside('src', 'src/foo.c'))
 
87
        self.assertFalse(is_inside('src', 'srccontrol'))
 
88
        self.assertTrue(is_inside('src', 'src/a/a/a/foo.c'))
 
89
        self.assertTrue(is_inside('foo.c', 'foo.c'))
 
90
        self.assertFalse(is_inside('foo.c', ''))
 
91
        self.assertTrue(is_inside('', 'foo.c'))
81
92
 
82
93
    def test_rmtree(self):
83
94
        # Check to remove tree with read-only files/dirs
311
322
        except (IOError, OSError), e:
312
323
            self.assertEqual(errno.ENOENT, e.errno)
313
324
 
 
325
    def test_splitpath(self):
 
326
        def check(expected, path):
 
327
            self.assertEqual(expected, osutils.splitpath(path))
 
328
 
 
329
        check(['a'], 'a')
 
330
        check(['a', 'b'], 'a/b')
 
331
        check(['a', 'b'], 'a/./b')
 
332
        check(['a', '.b'], 'a/.b')
 
333
        check(['a', '.b'], 'a\\.b')
 
334
 
 
335
        self.assertRaises(errors.BzrError, osutils.splitpath, 'a/../b')
 
336
 
314
337
 
315
338
class TestMacFuncsDirs(TestCaseInTempDir):
316
339
    """Test mac special functions that require directories."""
336
359
        os.chdir(u'Ba\u030agfors')
337
360
        self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
338
361
 
 
362
 
339
363
class TestSplitLines(TestCase):
340
364
 
341
365
    def test_split_unicode(self):