~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: 2006-09-13 02:44:23 UTC
  • mto: This revision was merged to the branch mainline in revision 2071.
  • Revision ID: john@arbash-meinel.com-20060913024423-2f0729076ddd4e31
lazy_import osutils and sign_my_commits
Move doc tests into test_osutils, since lazy_import doesn't play nicely
with DocTest

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
275
286
        except (IOError, OSError), e:
276
287
            self.assertEqual(errno.ENOENT, e.errno)
277
288
 
 
289
    def test_splitpath(self):
 
290
        def check(expected, path):
 
291
            self.assertEqual(expected, osutils.splitpath(path))
 
292
 
 
293
        check(['a'], 'a')
 
294
        check(['a', 'b'], 'a/b')
 
295
        check(['a', 'b'], 'a/./b')
 
296
        check(['a', '.b'], 'a/.b')
 
297
        check(['a', '.b'], 'a\\.b')
 
298
 
 
299
        self.assertRaises(errors.BzrError, osutils.splitpath, 'a/../b')
 
300
 
278
301
 
279
302
class TestMacFuncsDirs(TestCaseInTempDir):
280
303
    """Test mac special functions that require directories."""
300
323
        os.chdir(u'Ba\u030agfors')
301
324
        self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
302
325
 
 
326
 
303
327
class TestSplitLines(TestCase):
304
328
 
305
329
    def test_split_unicode(self):