1976
1975
del os.environ['COLUMNS']
1977
1976
# Whatever the result is, if we don't raise an exception, it's ok.
1978
1977
osutils.terminal_width()
1980
class TestCreationOps(tests.TestCaseInTempDir):
1981
_test_needs_features = [features.chown_feature]
1984
tests.TestCaseInTempDir.setUp(self)
1985
self.overrideAttr(os, 'chown', self._dummy_chown)
1987
# params set by call to _dummy_chown
1988
self.path = self.uid = self.gid = None
1990
def _dummy_chown(self, path, uid, gid):
1991
self.path, self.uid, self.gid = path, uid, gid
1993
def test_mkdir_with_ownership_chown(self):
1994
"""Ensure that osutils.mkdir_with_ownership chowns correctly with ownership_src.
1997
osutils.mkdir_with_ownership('foo', ownsrc)
2000
self.assertEquals(self.path, 'foo')
2001
self.assertEquals(self.uid, s.st_uid)
2002
self.assertEquals(self.gid, s.st_gid)
2004
def test_open_with_ownership_chown(self):
2005
"""Ensure that osutils.open_with_ownership chowns correctly with ownership_src.
2008
f = osutils.open_with_ownership('foo', 'w', ownership_src=ownsrc)
2010
# do a test write and close
2015
self.assertEquals(self.path, 'foo')
2016
self.assertEquals(self.uid, s.st_uid)
2017
self.assertEquals(self.gid, s.st_gid)