~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-04 16:06:36 UTC
  • mfrom: (5007 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5023.
  • Revision ID: john@arbash-meinel.com-20100204160636-xqeuwz8bwt8bbts4
Merge bzr.dev 5007, resolve conflict, update NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005-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
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',
1543
1548
        }
1544
1549
        self.__old_env = {}
1545
1550
        self.addCleanup(self._restoreEnvironment)
4130
4135
    should really use a different feature.
4131
4136
    """
4132
4137
 
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
4140
4149
 
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
 
4158
            # deprecated one.
 
4159
            mod = __import__(self._replacement_module, {}, {},
 
4160
                             [self._replacement_name])
 
4161
            self._feature = getattr(mod, self._replacement_name)
4148
4162
 
4149
4163
    def _probe(self):
4150
4164
        self._ensure()
4176
4190
        if self.available(): # Make sure the probe has been done
4177
4191
            return self._module
4178
4192
        return None
4179
 
    
 
4193
 
4180
4194
    def feature_name(self):
4181
4195
        return self.module_name
4182
4196
 
4183
4197
 
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')
4188
4203
 
4189
4204
 
4190
4205
def probe_unicode_in_user_encoding():
4352
4367
 
4353
4368
 
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.
4358
4374
try:
4359
4375
    from subunit import TestProtocolClient