~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/features.py

(gz) Never raise KnownFailure in tests,
 use knownFailure method instead (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""
19
19
 
20
20
import os
21
 
import subprocess
22
21
import stat
23
22
import sys
24
23
import tempfile
26
25
from bzrlib import (
27
26
    osutils,
28
27
    symbol_versioning,
 
28
    tests,
29
29
    )
30
30
 
31
31
 
140
140
                                            % (self._module, self._name))
141
141
            use_msg = ' Use %s.%s instead.' % (self._replacement_module,
142
142
                                               self._replacement_name)
143
 
            symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning,
144
 
                                   stacklevel=5)
 
143
            symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning)
145
144
            # Import the new feature and use it as a replacement for the
146
145
            # deprecated one.
147
146
            self._feature = pyutils.get_named_object(
166
165
        self.module_name = module_name
167
166
 
168
167
    def _probe(self):
169
 
        sentinel = object()
170
 
        module = sys.modules.get(self.module_name, sentinel)
171
 
        if module is sentinel:
172
 
            try:
173
 
                self._module = __import__(self.module_name, {}, {}, [''])
174
 
                return True
175
 
            except ImportError:
176
 
                return False
177
 
        else:
178
 
            self._module = module
 
168
        try:
 
169
            self._module = __import__(self.module_name, {}, {}, [''])
179
170
            return True
 
171
        except ImportError:
 
172
            return False
180
173
 
181
174
    @property
182
175
    def module(self):
290
283
        if CaseInsCasePresFilenameFeature.available():
291
284
            return False
292
285
 
293
 
        from bzrlib import tests
294
 
 
295
286
        if tests.TestCaseWithMemoryTransport.TEST_ROOT is None:
296
287
            root = osutils.mkdtemp(prefix='testbzr-', suffix='.tmp')
297
288
            tests.TestCaseWithMemoryTransport.TEST_ROOT = root
348
339
apport = ModuleAvailableFeature('apport')
349
340
gpgme = ModuleAvailableFeature('gpgme')
350
341
lzma = ModuleAvailableFeature('lzma')
351
 
meliae = ModuleAvailableFeature('meliae.scanner')
 
342
meliae = ModuleAvailableFeature('meliae')
352
343
paramiko = ModuleAvailableFeature('paramiko')
353
344
pycurl = ModuleAvailableFeature('pycurl')
354
345
pywintypes = ModuleAvailableFeature('pywintypes')
358
349
 
359
350
compiled_patiencediff_feature = ModuleAvailableFeature(
360
351
    'bzrlib._patiencediff_c')
 
352
meliae_feature = ModuleAvailableFeature('meliae.scanner')
361
353
lsprof_feature = ModuleAvailableFeature('bzrlib.lsprof')
362
354
 
363
355
 
409
401
 
410
402
 
411
403
bash_feature = ExecutableFeature('bash')
 
404
sed_feature = ExecutableFeature('sed')
412
405
diff_feature = ExecutableFeature('diff')
413
 
sed_feature = ExecutableFeature('sed')
414
 
msgmerge_feature = ExecutableFeature('msgmerge')
415
406
 
416
407
 
417
408
class _PosixPermissionsFeature(Feature):
424
415
            f = tempfile.mkstemp(prefix='bzr_perms_chk_')
425
416
            fd, name = f
426
417
            os.close(fd)
427
 
            osutils.chmod_if_possible(name, write_perms)
 
418
            os.chmod(name, write_perms)
428
419
 
429
420
            read_perms = os.stat(name).st_mode & 0777
430
421
            os.unlink(name)
493
484
 
494
485
 
495
486
win32_feature = Win32Feature()
 
487
 
 
488
 
 
489
for name in ['HTTPServerFeature', 
 
490
    'HTTPSServerFeature', 'SymlinkFeature', 'HardlinkFeature',
 
491
    'OsFifoFeature', 'UnicodeFilenameFeature',
 
492
    'ByteStringNamedFilesystem', 'UTF8Filesystem',
 
493
    'BreakinFeature', 'CaseInsCasePresFilenameFeature',
 
494
    'CaseInsensitiveFilesystemFeature', 'case_sensitive_filesystem_feature',
 
495
    'posix_permissions_feature',
 
496
    ]:
 
497
    setattr(tests, name, _CompatabilityThunkFeature(
 
498
        symbol_versioning.deprecated_in((2, 5, 0)),
 
499
        'bzrlib.tests', name,
 
500
        name, 'bzrlib.tests.features'))
 
501
 
 
502
 
 
503
for (old_name, new_name) in [
 
504
    ('UnicodeFilename', 'UnicodeFilenameFeature'),
 
505
    ]:
 
506
    setattr(tests, name, _CompatabilityThunkFeature(
 
507
        symbol_versioning.deprecated_in((2, 5, 0)),
 
508
        'bzrlib.tests', old_name,
 
509
        new_name, 'bzrlib.tests.features'))