~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_permissions.py

Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__.

This is used to replace various ad hoc implementations of the same logic,
notably the version used in registry's _LazyObjectGetter which had a bug when
getting a module without also getting a member.  And of course, this new
function has unit tests, unlike the replaced code.

This also adds a KnownHooksRegistry subclass to provide a more natural home for
some other logic.

I'm not thrilled about the name of the new module or the new functions, but it's
hard to think of good names for such generic functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 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
36
36
from cStringIO import StringIO
37
37
import urllib
38
38
 
 
39
from bzrlib import transport
39
40
from bzrlib.branch import Branch
40
41
from bzrlib.bzrdir import BzrDir
41
42
from bzrlib.tests import TestCaseWithTransport, TestSkipped
42
43
from bzrlib.tests.test_sftp_transport import TestCaseWithSFTPServer
43
 
from bzrlib.transport import get_transport
44
44
from bzrlib.workingtree import WorkingTree
45
45
 
46
46
 
65
65
    :param dir_mode: The mode for all directories
66
66
    :param include_base: If false, only check the subdirectories
67
67
    """
68
 
    t = get_transport(".")
 
68
    t = transport.get_transport(".")
69
69
    if include_base:
70
70
        test.assertTransportMode(t, base, dir_mode)
71
71
    for root, dirs, files in os.walk(base):
180
180
 
181
181
        # bodge around for stubsftpserver not letting use connect
182
182
        # more than once
183
 
        _t = get_transport(self.get_url())
 
183
        _t = transport.get_transport(self.get_url())
184
184
 
185
185
        os.mkdir('local')
186
186
        t_local = self.make_branch_and_tree('local')
257
257
        original_umask = os.umask(umask)
258
258
 
259
259
        try:
260
 
            t = get_transport(self.get_url())
 
260
            t = transport.get_transport(self.get_url())
261
261
            # Direct access should be masked by umask
262
262
            t._sftp_open_exclusive('a', mode=0666).write('foo\n')
263
263
            self.assertTransportMode(t, 'a', 0666 &~umask)