~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/features.py

  • Committer: Martin Pool
  • Date: 2010-08-18 07:25:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5383.
  • Revision ID: mbp@sourcefrog.net-20100818072522-uk3gsazoia3l3s0a
Start adding 'what's new in 2.3'

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
 
 
23
 
from bzrlib import (
24
 
    osutils,
25
 
    tests,
26
 
    )
27
 
 
28
 
 
29
 
class _NotRunningAsRoot(tests.Feature):
30
 
 
31
 
    def _probe(self):
32
 
        try:
33
 
            uid = os.getuid()
34
 
        except AttributeError:
35
 
            # If there is no uid, chances are there is no root either
36
 
            return True
37
 
        return uid != 0
38
 
 
39
 
    def feature_name(self):
40
 
        return 'Not running as root'
41
 
 
42
 
 
43
 
not_running_as_root = _NotRunningAsRoot()
 
21
 
 
22
from bzrlib import tests
 
23
from bzrlib.symbol_versioning import deprecated_in
 
24
 
44
25
 
45
26
apport = tests.ModuleAvailableFeature('apport')
46
 
gpgme = tests.ModuleAvailableFeature('gpgme')
47
 
lzma = tests.ModuleAvailableFeature('lzma')
48
 
meliae = tests.ModuleAvailableFeature('meliae')
49
27
paramiko = tests.ModuleAvailableFeature('paramiko')
50
28
pycurl = tests.ModuleAvailableFeature('pycurl')
51
29
pywintypes = tests.ModuleAvailableFeature('pywintypes')
 
30
subunit = tests.ModuleAvailableFeature('subunit')
52
31
sphinx = tests.ModuleAvailableFeature('sphinx')
53
 
subunit = tests.ModuleAvailableFeature('subunit')
54
 
testtools = tests.ModuleAvailableFeature('testtools')
55
32
 
56
33
 
57
34
class _BackslashDirSeparatorFeature(tests.Feature):
120
97
        return self._path
121
98
 
122
99
    def _probe(self):
123
 
        self._path = osutils.find_executable_on_path(self.name)
124
 
        return self._path is not None
 
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
125
110
 
126
111
    def feature_name(self):
127
112
        return '%s executable' % self.name
129
114
 
130
115
bash_feature = ExecutableFeature('bash')
131
116
sed_feature = ExecutableFeature('sed')
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()