~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: 2010-03-24 07:27:44 UTC
  • mfrom: (5094.3.2 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100324072744-2fod6mq1jqijs7c0
(mbp, for parthm) inherit permissions on \~/.bazaar etc

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,
36
37
    file_utils,
37
38
    test__walkdirs_win32,
38
39
    )
1975
1976
        del os.environ['COLUMNS']
1976
1977
        # Whatever the result is, if we don't raise an exception, it's ok.
1977
1978
        osutils.terminal_width()
 
1979
 
 
1980
class TestCreationOps(tests.TestCaseInTempDir):
 
1981
    _test_needs_features = [features.chown_feature]
 
1982
 
 
1983
    def setUp(self):
 
1984
        tests.TestCaseInTempDir.setUp(self)
 
1985
        self.overrideAttr(os, 'chown', self._dummy_chown)
 
1986
 
 
1987
        # params set by call to _dummy_chown
 
1988
        self.path = self.uid = self.gid = None
 
1989
 
 
1990
    def _dummy_chown(self, path, uid, gid):
 
1991
        self.path, self.uid, self.gid = path, uid, gid
 
1992
 
 
1993
    def test_mkdir_with_ownership_chown(self):
 
1994
        """Ensure that osutils.mkdir_with_ownership chowns correctly with ownership_src.
 
1995
        """
 
1996
        ownsrc = '/'
 
1997
        osutils.mkdir_with_ownership('foo', ownsrc)
 
1998
 
 
1999
        s = os.stat(ownsrc)
 
2000
        self.assertEquals(self.path, 'foo')
 
2001
        self.assertEquals(self.uid, s.st_uid)
 
2002
        self.assertEquals(self.gid, s.st_gid)
 
2003
 
 
2004
    def test_open_with_ownership_chown(self):
 
2005
        """Ensure that osutils.open_with_ownership chowns correctly with ownership_src.
 
2006
        """
 
2007
        ownsrc = '/'
 
2008
        f = osutils.open_with_ownership('foo', 'w', ownership_src=ownsrc)
 
2009
 
 
2010
        # do a test write and close
 
2011
        f.write('hello')
 
2012
        f.close()
 
2013
 
 
2014
        s = os.stat(ownsrc)
 
2015
        self.assertEquals(self.path, 'foo')
 
2016
        self.assertEquals(self.uid, s.st_uid)
 
2017
        self.assertEquals(self.gid, s.st_gid)
 
2018