184
183
shape = sorted(os.listdir('.'))
185
184
self.assertEquals(['A', 'B'], shape)
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')
195
187
class TestRandChars(tests.TestCase):
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()
1987
class TestCreationOps(tests.TestCaseInTempDir):
1988
_test_needs_features = [features.chown_feature]
1991
tests.TestCaseInTempDir.setUp(self)
1992
self.overrideAttr(os, 'chown', self._dummy_chown)
1994
# params set by call to _dummy_chown
1995
self.path = self.uid = self.gid = None
1997
def _dummy_chown(self, path, uid, gid):
1998
self.path, self.uid, self.gid = path, uid, gid
2000
def test_copy_ownership_from_path(self):
2001
"""copy_ownership_from_path test with specified src."""
2003
f = open('test_file', 'wt')
2004
osutils.copy_ownership_from_path('test_file', ownsrc)
2007
self.assertEquals(self.path, 'test_file')
2008
self.assertEquals(self.uid, s.st_uid)
2009
self.assertEquals(self.gid, s.st_gid)
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')
2018
self.assertEquals(self.path, 'test_file')
2019
self.assertEquals(self.uid, s.st_uid)
2020
self.assertEquals(self.gid, s.st_gid)