/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Parth Malwankar
  • Date: 2010-03-06 05:28:17 UTC
  • mto: (5094.3.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5107.
  • Revision ID: parth.malwankar@gmail.com-20100306052817-5ygp4co5l6frp0d1
removed parent_dir.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1977
1977
        osutils.terminal_width()
1978
1978
 
1979
1979
class TestCreationOps(tests.TestCaseInTempDir):
 
1980
    _test_needs_features = [tests.ChownFeature]
1980
1981
 
1981
1982
    def setUp(self):
1982
1983
        tests.TestCaseInTempDir.setUp(self)
1983
 
 
1984
 
        # we can't overrideAttr os.chown on OS that doesn't support chown
1985
 
        if os.name == 'posix' and hasattr(os, 'chown'):
1986
 
            self.overrideAttr(os, 'chown', self._dummy_chown)
 
1984
        self.overrideAttr(os, 'chown', self._dummy_chown)
1987
1985
 
1988
1986
        # params set by call to _dummy_chown
1989
1987
        self.path = self.uid = self.gid = None
1991
1989
    def _dummy_chown(self, path, uid, gid):
1992
1990
        self.path, self.uid, self.gid = path, uid, gid
1993
1991
 
1994
 
    def test_mkdir_with_ownership_no_chown(self):
1995
 
        """ensure that osutils.mkdir_with_ownership does not chown without ownership_src arg"""
1996
 
        self.requireFeature(tests.ChownFeature)
1997
 
        osutils.mkdir_with_ownership('foo')
1998
 
        self.assertEquals(self.path, None)
1999
 
        self.assertEquals(self.uid, None)
2000
 
        self.assertEquals(self.gid, None)
2001
 
 
2002
1992
    def test_mkdir_with_ownership_chown(self):
2003
1993
        """ensure that osutils.mkdir_with_ownership chowns correctly with ownership_src arg"""
2004
 
        self.requireFeature(tests.ChownFeature)
2005
1994
        ownsrc = '/'
2006
1995
        osutils.mkdir_with_ownership('foo', ownsrc)
2007
1996
 
2010
1999
        self.assertEquals(self.uid, s.st_uid)
2011
2000
        self.assertEquals(self.gid, s.st_gid)
2012
2001
 
2013
 
    def test_open_with_ownership_no_chown(self):
2014
 
        """ensure that osutils.open_with_ownership does not chown without ownership_src arg"""
2015
 
        self.requireFeature(tests.ChownFeature)
2016
 
        f = osutils.open_with_ownership('foo', 'w')
2017
 
 
2018
 
        # do a test write and close
2019
 
        f.write('hello')
2020
 
        f.close()
2021
 
 
2022
 
        self.assertEquals(self.path, None)
2023
 
        self.assertEquals(self.uid, None)
2024
 
        self.assertEquals(self.gid, None)
2025
 
 
2026
2002
    def test_open_with_ownership_chown(self):
2027
2003
        """ensure that osutils.open_with_ownership chowns correctly with ownership_src arg"""
2028
 
        self.requireFeature(tests.ChownFeature)
2029
2004
        ownsrc = '/'
2030
2005
        f = osutils.open_with_ownership('foo', 'w', ownership_src=ownsrc)
2031
2006
 
2038
2013
        self.assertEquals(self.uid, s.st_uid)
2039
2014
        self.assertEquals(self.gid, s.st_gid)
2040
2015
 
2041
 
    def test_parent_dir(self):
2042
 
        self.assertEquals(osutils.parent_dir('/a/b/c'), '/a/b')
2043
 
        self.assertEquals(osutils.parent_dir('x'), '.')
2044