4135
4135
should really use a different feature.
4138
def __init__(self, module, name, this_name, dep_version):
4138
def __init__(self, dep_version, module, name,
4139
replacement_name, replacement_module=None):
4139
4140
super(_CompatabilityThunkFeature, self).__init__()
4140
4141
self._module = module
4142
if replacement_module is None:
4143
replacement_module = module
4144
self._replacement_module = replacement_module
4141
4145
self._name = name
4142
self._this_name = this_name
4146
self._replacement_name = replacement_name
4143
4147
self._dep_version = dep_version
4144
4148
self._feature = None
4146
4150
def _ensure(self):
4147
4151
if self._feature is None:
4148
msg = (self._dep_version % self._this_name) + (
4149
' Use %s.%s instead.' % (self._module, self._name))
4150
symbol_versioning.warn(msg, DeprecationWarning)
4151
mod = __import__(self._module, {}, {}, [self._name])
4152
self._feature = getattr(mod, self._name)
4152
depr_msg = self._dep_version % ('%s.%s'
4153
% (self._module, self._name))
4154
use_msg = ' Use %s.%s instead.' % (self._replacement_module,
4155
self._replacement_name)
4156
symbol_versioning.warn(depr_msg + use_msg, DeprecationWarning)
4157
# Import the new feature and use it as a replacement for the
4159
mod = __import__(self._replacement_module, {}, {},
4160
[self._replacement_name])
4161
self._feature = getattr(mod, self._replacement_name)
4154
4163
def _probe(self):
4181
4190
if self.available(): # Make sure the probe has been done
4182
4191
return self._module
4185
4194
def feature_name(self):
4186
4195
return self.module_name
4189
4198
# This is kept here for compatibility, it is recommended to use
4190
4199
# 'bzrlib.tests.feature.paramiko' instead
4191
ParamikoFeature = _CompatabilityThunkFeature('bzrlib.tests.features',
4192
'paramiko', 'bzrlib.tests.ParamikoFeature', deprecated_in((2,1,0)))
4200
ParamikoFeature = _CompatabilityThunkFeature(
4201
deprecated_in((2,1,0)),
4202
'bzrlib.tests.features', 'ParamikoFeature', 'paramiko')
4195
4205
def probe_unicode_in_user_encoding():
4359
4369
# Kept for compatibility, use bzrlib.tests.features.subunit instead
4360
SubUnitFeature = _CompatabilityThunkFeature('bzrlib.tests.features', 'subunit',
4361
'bzrlib.tests.SubUnitFeature', deprecated_in((2,1,0)))
4370
SubUnitFeature = _CompatabilityThunkFeature(
4371
deprecated_in((2,1,0)),
4372
'bzrlib.tests.features', 'SubUnitFeature', 'subunit')
4362
4373
# Only define SubUnitBzrRunner if subunit is available.
4364
4375
from subunit import TestProtocolClient