~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/features.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-13 00:26:41 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101013002641-9tlh9k89mlj1666m
Keep docs-plain working.

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
18
18
 
19
19
import os
20
20
import stat
21
 
import sys
22
21
 
23
 
from bzrlib import (
24
 
    osutils,
25
 
    tests,
26
 
    )
 
22
from bzrlib import tests
 
23
from bzrlib.symbol_versioning import deprecated_in
27
24
 
28
25
 
29
26
class _NotRunningAsRoot(tests.Feature):
41
38
 
42
39
 
43
40
not_running_as_root = _NotRunningAsRoot()
44
 
 
45
41
apport = tests.ModuleAvailableFeature('apport')
46
 
gpgme = tests.ModuleAvailableFeature('gpgme')
47
 
lzma = tests.ModuleAvailableFeature('lzma')
48
 
meliae = tests.ModuleAvailableFeature('meliae')
49
42
paramiko = tests.ModuleAvailableFeature('paramiko')
50
43
pycurl = tests.ModuleAvailableFeature('pycurl')
51
44
pywintypes = tests.ModuleAvailableFeature('pywintypes')
 
45
subunit = tests.ModuleAvailableFeature('subunit')
52
46
sphinx = tests.ModuleAvailableFeature('sphinx')
53
 
subunit = tests.ModuleAvailableFeature('subunit')
54
 
testtools = tests.ModuleAvailableFeature('testtools')
55
47
 
56
48
 
57
49
class _BackslashDirSeparatorFeature(tests.Feature):
120
112
        return self._path
121
113
 
122
114
    def _probe(self):
123
 
        self._path = osutils.find_executable_on_path(self.name)
124
 
        return self._path is not None
 
115
        path = os.environ.get('PATH')
 
116
        if path is None:
 
117
            return False
 
118
        for d in path.split(os.pathsep):
 
119
            if d:
 
120
                f = os.path.join(d, self.name)
 
121
                if os.access(f, os.X_OK):
 
122
                    self._path = f
 
123
                    return True
 
124
        return False
125
125
 
126
126
    def feature_name(self):
127
127
        return '%s executable' % self.name
130
130
bash_feature = ExecutableFeature('bash')
131
131
sed_feature = ExecutableFeature('sed')
132
132
diff_feature = ExecutableFeature('diff')
133
 
 
134
 
 
135
 
class Win32Feature(tests.Feature):
136
 
    """Feature testing whether we're running selftest on Windows
137
 
    or Windows-like platform.
138
 
    """
139
 
 
140
 
    def _probe(self):
141
 
        return sys.platform == 'win32'
142
 
 
143
 
    def feature_name(self):
144
 
        return "win32 platform"
145
 
 
146
 
win32_feature = Win32Feature()