/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:
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
 
26
24
apport = tests.ModuleAvailableFeature('apport')
27
25
paramiko = tests.ModuleAvailableFeature('paramiko')
28
26
pycurl = tests.ModuleAvailableFeature('pycurl')
29
 
pywintypes = tests.ModuleAvailableFeature('pywintypes')
30
27
subunit = tests.ModuleAvailableFeature('subunit')
31
28
 
32
29
 
33
 
class _BackslashDirSeparatorFeature(tests.Feature):
34
 
 
35
 
    def _probe(self):
36
 
        try:
37
 
            os.lstat(os.getcwd() + '\\')
38
 
        except OSError:
39
 
            return False
40
 
        else:
41
 
            return True
42
 
 
43
 
    def feature_name(self):
44
 
        return "Filesystem treats '\\' as a directory separator."
45
 
 
46
 
backslashdir_feature = _BackslashDirSeparatorFeature()
47
 
 
48
 
 
49
30
class _PosixPermissionsFeature(tests.Feature):
50
31
 
51
32
    def _probe(self):
80
61
 
81
62
chown_feature = _ChownFeature()
82
63
 
83
 
 
84
 
class ExecutableFeature(tests.Feature):
85
 
    """Feature testing whether an executable of a given name is on the PATH."""
86
 
 
87
 
    def __init__(self, name):
88
 
        super(ExecutableFeature, self).__init__()
89
 
        self.name = name
90
 
        self._path = None
91
 
 
92
 
    @property
93
 
    def path(self):
94
 
        # This is a property, so accessing path ensures _probe was called
95
 
        self.available()
96
 
        return self._path
97
 
 
98
 
    def _probe(self):
99
 
        path = os.environ.get('PATH')
100
 
        if path is None:
101
 
            return False
102
 
        for d in path.split(os.pathsep):
103
 
            if d:
104
 
                f = os.path.join(d, self.name)
105
 
                if os.access(f, os.X_OK):
106
 
                    self._path = f
107
 
                    return True
108
 
        return False
109
 
 
110
 
    def feature_name(self):
111
 
        return '%s executable' % self.name
112
 
 
113
 
 
114
 
bash_feature = ExecutableFeature('bash')
115
 
sed_feature = ExecutableFeature('sed')