1
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Canonical Ltd
1
# Copyright (C) 2005-2010 Canonical Ltd
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
1540
1540
'ftp_proxy': None,
1541
1541
'FTP_PROXY': None,
1542
1542
'BZR_REMOTE_PATH': None,
1543
# Generally speaking, we don't want apport reporting on crashes in
1544
# the test envirnoment unless we're specifically testing apport,
1545
# so that it doesn't leak into the real system environment. We
1546
# use an env var so it propagates to subprocesses.
1547
'APPORT_DISABLE': '1',
1544
1549
self.__old_env = {}
1545
1550
self.addCleanup(self._restoreEnvironment)
4130
4135
should really use a different feature.
4133
def __init__(self, module, name, this_name, dep_version):
4138
def __init__(self, dep_version, module, name,
4139
replacement_name, replacement_module=None):
4134
4140
super(_CompatabilityThunkFeature, self).__init__()
4135
4141
self._module = module
4142
if replacement_module is None:
4143
replacement_module = module
4144
self._replacement_module = replacement_module
4136
4145
self._name = name
4137
self._this_name = this_name
4146
self._replacement_name = replacement_name
4138
4147
self._dep_version = dep_version
4139
4148
self._feature = None
4141
4150
def _ensure(self):
4142
4151
if self._feature is None:
4143
msg = (self._dep_version % self._this_name) + (
4144
' Use %s.%s instead.' % (self._module, self._name))
4145
symbol_versioning.warn(msg, DeprecationWarning)
4146
mod = __import__(self._module, {}, {}, [self._name])
4147
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)
4149
4163
def _probe(self):
4176
4190
if self.available(): # Make sure the probe has been done
4177
4191
return self._module
4180
4194
def feature_name(self):
4181
4195
return self.module_name
4184
4198
# This is kept here for compatibility, it is recommended to use
4185
4199
# 'bzrlib.tests.feature.paramiko' instead
4186
ParamikoFeature = _CompatabilityThunkFeature('bzrlib.tests.features',
4187
'paramiko', 'bzrlib.tests.ParamikoFeature', deprecated_in((2,1,0)))
4200
ParamikoFeature = _CompatabilityThunkFeature(
4201
deprecated_in((2,1,0)),
4202
'bzrlib.tests.features', 'ParamikoFeature', 'paramiko')
4190
4205
def probe_unicode_in_user_encoding():
4354
4369
# Kept for compatibility, use bzrlib.tests.features.subunit instead
4355
SubUnitFeature = _CompatabilityThunkFeature('bzrlib.tests.features', 'subunit',
4356
'bzrlib.tests.SubUnitFeature', deprecated_in((2,1,0)))
4370
SubUnitFeature = _CompatabilityThunkFeature(
4371
deprecated_in((2,1,0)),
4372
'bzrlib.tests.features', 'SubUnitFeature', 'subunit')
4357
4373
# Only define SubUnitBzrRunner if subunit is available.
4359
4375
from subunit import TestProtocolClient