~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_permissions.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-13 06:14:37 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101013061437-2e2m9gro1eusnbb8
Tweaks to the sphinx build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
32
32
 
33
33
import os
34
34
import sys
 
35
import stat
 
36
from cStringIO import StringIO
 
37
import urllib
35
38
 
36
 
from bzrlib import urlutils
 
39
from bzrlib import transport
37
40
from bzrlib.branch import Branch
38
41
from bzrlib.bzrdir import BzrDir
39
42
from bzrlib.tests import TestCaseWithTransport, TestSkipped
62
65
    :param dir_mode: The mode for all directories
63
66
    :param include_base: If false, only check the subdirectories
64
67
    """
65
 
    t = test.get_transport()
 
68
    t = transport.get_transport(".")
66
69
    if include_base:
67
70
        test.assertTransportMode(t, base, dir_mode)
68
71
    for root, dirs, files in os.walk(base):
69
72
        for d in dirs:
70
 
            p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [d]])
 
73
            p = '/'.join([urllib.quote(x) for x in root.split('/\\') + [d]])
71
74
            test.assertTransportMode(t, p, dir_mode)
72
75
        for f in files:
73
76
            p = os.path.join(root, f)
74
 
            p = '/'.join([urlutils.quote(x) for x in root.split('/\\') + [f]])
 
77
            p = '/'.join([urllib.quote(x) for x in root.split('/\\') + [f]])
75
78
            test.assertTransportMode(t, p, file_mode)
76
79
 
77
80
 
137
140
    def test_new_files_group_sticky_bit(self):
138
141
        if sys.platform == 'win32':
139
142
            raise TestSkipped('chmod has no effect on win32')
140
 
        elif sys.platform == 'darwin' or 'freebsd' in sys.platform:
141
 
            # FreeBSD-based platforms create temp dirs with the 'wheel' group,
142
 
            # which users are not likely to be in, and this prevents us from
143
 
            # setting the sgid bit
 
143
        elif sys.platform == 'darwin' or sys.platform.startswith('freebsd'):
 
144
            # OS X (and FreeBSD) create temp dirs with the 'wheel' group, which
 
145
            # users are not likely to be in, and this prevents us from setting
 
146
            # the sgid bit
144
147
            os.chown(self.test_dir, os.getuid(), os.getgid())
145
148
 
146
149
        t = self.make_branch_and_tree('.')
177
180
 
178
181
        # bodge around for stubsftpserver not letting use connect
179
182
        # more than once
180
 
        _t = self.get_transport()
 
183
        _t = transport.get_transport(self.get_url())
181
184
 
182
185
        os.mkdir('local')
183
186
        t_local = self.make_branch_and_tree('local')
254
257
        original_umask = os.umask(umask)
255
258
 
256
259
        try:
257
 
            t = self.get_transport()
 
260
            t = transport.get_transport(self.get_url())
258
261
            # Direct access should be masked by umask
259
262
            t._sftp_open_exclusive('a', mode=0666).write('foo\n')
260
263
            self.assertTransportMode(t, 'a', 0666 &~umask)