4248
4249
UnicodeFilenameFeature = _UnicodeFilenameFeature()
4252
class _CompatabilityThunkFeature(Feature):
4253
"""This feature is just a thunk to another feature.
4255
It issues a deprecation warning if it is accessed, to let you know that you
4256
should really use a different feature.
4259
def __init__(self, module, name, this_name, dep_version):
4260
super(_CompatabilityThunkFeature, self).__init__()
4261
self._module = module
4263
self._this_name = this_name
4264
self._dep_version = dep_version
4265
self._feature = None
4268
if self._feature is None:
4269
msg = (self._dep_version % self._this_name) + (
4270
' Use %s.%s instead.' % (self._module, self._name))
4271
symbol_versioning.warn(msg, DeprecationWarning)
4272
mod = __import__(self._module, {}, {}, [self._name])
4273
self._feature = getattr(mod, self._name)
4277
return self._feature._probe()
4251
4280
class ModuleAvailableFeature(Feature):
4252
4281
"""This is a feature than describes a module we want to be available.
4278
4307
return self.module_name
4310
# This is kept here for compatibility, it is recommended to use
4311
# 'bzrlib.tests.feature.paramiko' instead
4312
ParamikoFeature = _CompatabilityThunkFeature('bzrlib.tests.features',
4313
'paramiko', 'bzrlib.tests.ParamikoFeature', deprecated_in((2,1,0)))
4282
4316
def probe_unicode_in_user_encoding():
4283
4317
"""Try to encode several unicode strings to use in unicode-aware tests.
4333
4367
HTTPSServerFeature = _HTTPSServerFeature()
4336
class _ParamikoFeature(Feature):
4337
"""Is paramiko available?"""
4341
from bzrlib.transport.sftp import SFTPAbsoluteServer
4343
except errors.ParamikoNotPresent:
4346
def feature_name(self):
4350
ParamikoFeature = _ParamikoFeature()
4353
4370
class _UnicodeFilename(Feature):
4354
4371
"""Does the filesystem support Unicode filenames?"""
4460
4477
CaseInsensitiveFilesystemFeature = _CaseInsensitiveFilesystemFeature()
4463
class _SubUnitFeature(Feature):
4464
"""Check if subunit is available."""
4473
def feature_name(self):
4476
SubUnitFeature = _SubUnitFeature()
4480
# Kept for compatibility, use bzrlib.tests.features.subunit instead
4481
SubUnitFeature = _CompatabilityThunkFeature('bzrlib.tests.features', 'subunit',
4482
'bzrlib.tests.SubUnitFeature', deprecated_in((2,1,0)))
4477
4483
# Only define SubUnitBzrRunner if subunit is available.
4479
4485
from subunit import TestProtocolClient