/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/features.py

  • Committer: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010, 2011 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 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
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""A collection of commonly used 'Features' which bzrlib uses to skip tests."""
18
 
 
19
17
import os
20
18
import stat
21
19
 
22
 
from bzrlib import (
23
 
    osutils,
24
 
    tests,
25
 
    )
26
 
 
27
 
 
28
 
class _NotRunningAsRoot(tests.Feature):
29
 
 
30
 
    def _probe(self):
31
 
        try:
32
 
            uid = os.getuid()
33
 
        except AttributeError:
34
 
            # If there is no uid, chances are there is no root either
35
 
            return True
36
 
        return uid != 0
37
 
 
38
 
    def feature_name(self):
39
 
        return 'Not running as root'
40
 
 
41
 
 
42
 
not_running_as_root = _NotRunningAsRoot()
 
20
from bzrlib import tests
 
21
from bzrlib.symbol_versioning import deprecated_in
 
22
 
43
23
 
44
24
apport = tests.ModuleAvailableFeature('apport')
45
 
meliae = tests.ModuleAvailableFeature('meliae')
46
25
paramiko = tests.ModuleAvailableFeature('paramiko')
47
26
pycurl = tests.ModuleAvailableFeature('pycurl')
48
 
pywintypes = tests.ModuleAvailableFeature('pywintypes')
49
 
sphinx = tests.ModuleAvailableFeature('sphinx')
50
27
subunit = tests.ModuleAvailableFeature('subunit')
51
28
 
52
29
 
53
 
class _BackslashDirSeparatorFeature(tests.Feature):
54
 
 
55
 
    def _probe(self):
56
 
        try:
57
 
            os.lstat(os.getcwd() + '\\')
58
 
        except OSError:
59
 
            return False
60
 
        else:
61
 
            return True
62
 
 
63
 
    def feature_name(self):
64
 
        return "Filesystem treats '\\' as a directory separator."
65
 
 
66
 
backslashdir_feature = _BackslashDirSeparatorFeature()
67
 
 
68
 
 
69
30
class _PosixPermissionsFeature(tests.Feature):
70
31
 
71
32
    def _probe(self):
100
61
 
101
62
chown_feature = _ChownFeature()
102
63
 
103
 
 
104
 
class ExecutableFeature(tests.Feature):
105
 
    """Feature testing whether an executable of a given name is on the PATH."""
106
 
 
107
 
    def __init__(self, name):
108
 
        super(ExecutableFeature, self).__init__()
109
 
        self.name = name
110
 
        self._path = None
111
 
 
112
 
    @property
113
 
    def path(self):
114
 
        # This is a property, so accessing path ensures _probe was called
115
 
        self.available()
116
 
        return self._path
117
 
 
118
 
    def _probe(self):
119
 
        self._path = osutils.find_executable_on_path(self.name)
120
 
        return self._path is not None
121
 
 
122
 
    def feature_name(self):
123
 
        return '%s executable' % self.name
124
 
 
125
 
 
126
 
bash_feature = ExecutableFeature('bash')
127
 
sed_feature = ExecutableFeature('sed')
128
 
diff_feature = ExecutableFeature('diff')