~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/features.py

merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009, 2010, 2011 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
19
19
import os
20
20
import stat
21
21
 
22
 
from bzrlib import tests
23
 
from bzrlib.symbol_versioning import deprecated_in
24
 
 
 
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()
25
43
 
26
44
apport = tests.ModuleAvailableFeature('apport')
 
45
lzma = tests.ModuleAvailableFeature('lzma')
 
46
meliae = tests.ModuleAvailableFeature('meliae')
27
47
paramiko = tests.ModuleAvailableFeature('paramiko')
28
48
pycurl = tests.ModuleAvailableFeature('pycurl')
29
49
pywintypes = tests.ModuleAvailableFeature('pywintypes')
 
50
sphinx = tests.ModuleAvailableFeature('sphinx')
30
51
subunit = tests.ModuleAvailableFeature('subunit')
31
 
sphinx = tests.ModuleAvailableFeature('sphinx')
32
52
 
33
53
 
34
54
class _BackslashDirSeparatorFeature(tests.Feature):
97
117
        return self._path
98
118
 
99
119
    def _probe(self):
100
 
        path = os.environ.get('PATH')
101
 
        if path is None:
102
 
            return False
103
 
        for d in path.split(os.pathsep):
104
 
            if d:
105
 
                f = os.path.join(d, self.name)
106
 
                if os.access(f, os.X_OK):
107
 
                    self._path = f
108
 
                    return True
109
 
        return False
 
120
        self._path = osutils.find_executable_on_path(self.name)
 
121
        return self._path is not None
110
122
 
111
123
    def feature_name(self):
112
124
        return '%s executable' % self.name