~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-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
 
317
309
        self.assertEqual("/", osutils.kind_marker(osutils._directory_kind))
318
310
        self.assertEqual("@", osutils.kind_marker("symlink"))
319
311
        self.assertEqual("+", osutils.kind_marker("tree-reference"))
320
 
        self.assertEqual("", osutils.kind_marker("fifo"))
321
 
        self.assertEqual("", osutils.kind_marker("socket"))
322
 
        self.assertEqual("", osutils.kind_marker("unknown"))
 
312
        self.assertRaises(errors.BzrError, osutils.kind_marker, "unknown")
323
313
 
324
314
 
325
315
class TestUmask(tests.TestCaseInTempDir):
1983
1973
        del os.environ['COLUMNS']
1984
1974
        # Whatever the result is, if we don't raise an exception, it's ok.
1985
1975
        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)