~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Martin Pool
  • Date: 2010-03-15 06:54:44 UTC
  • mto: This revision was merged to the branch mainline in revision 5095.
  • Revision ID: mbp@canonical.com-20100315065444-gfs7vp8te4ez5rc9
Fix typo in ReadVFile.readline (thanks mnordhoff)

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    win32utils,
34
34
    )
35
35
from bzrlib.tests import (
36
 
    features,
37
36
    file_utils,
38
37
    test__walkdirs_win32,
39
38
    )
184
183
        shape = sorted(os.listdir('.'))
185
184
        self.assertEquals(['A', 'B'], shape)
186
185
 
187
 
    def test_rename_error(self):
188
 
        # We wrap os.rename to make it give an error including the filenames
189
 
        # https://bugs.launchpad.net/bzr/+bug/491763
190
 
        err = self.assertRaises(OSError, osutils.rename,
191
 
            'nonexistent', 'target')
192
 
        self.assertContainsString(str(err), 'nonexistent')
193
 
 
194
186
 
195
187
class TestRandChars(tests.TestCase):
196
188
 
1983
1975
        del os.environ['COLUMNS']
1984
1976
        # Whatever the result is, if we don't raise an exception, it's ok.
1985
1977
        osutils.terminal_width()
1986
 
 
1987
 
class TestCreationOps(tests.TestCaseInTempDir):
1988
 
    _test_needs_features = [features.chown_feature]
1989
 
 
1990
 
    def setUp(self):
1991
 
        tests.TestCaseInTempDir.setUp(self)
1992
 
        self.overrideAttr(os, 'chown', self._dummy_chown)
1993
 
 
1994
 
        # params set by call to _dummy_chown
1995
 
        self.path = self.uid = self.gid = None
1996
 
 
1997
 
    def _dummy_chown(self, path, uid, gid):
1998
 
        self.path, self.uid, self.gid = path, uid, gid
1999
 
 
2000
 
    def test_copy_ownership_from_path(self):
2001
 
        """copy_ownership_from_path test with specified src."""
2002
 
        ownsrc = '/'
2003
 
        f = open('test_file', 'wt')
2004
 
        osutils.copy_ownership_from_path('test_file', ownsrc)
2005
 
 
2006
 
        s = os.stat(ownsrc)
2007
 
        self.assertEquals(self.path, 'test_file')
2008
 
        self.assertEquals(self.uid, s.st_uid)
2009
 
        self.assertEquals(self.gid, s.st_gid)
2010
 
 
2011
 
    def test_copy_ownership_nonesrc(self):
2012
 
        """copy_ownership_from_path test with src=None."""
2013
 
        f = open('test_file', 'wt')
2014
 
        # should use parent dir for permissions
2015
 
        osutils.copy_ownership_from_path('test_file')
2016
 
 
2017
 
        s = os.stat('..')
2018
 
        self.assertEquals(self.path, 'test_file')
2019
 
        self.assertEquals(self.uid, s.st_uid)
2020
 
        self.assertEquals(self.gid, s.st_gid)