1
# Copyright (C) 2006, 2007 Canonical Ltd
2
# Authors: Robert Collins <robert.collins@canonical.com>
1
# Copyright (C) 2006, 2007, 2009 Canonical Ltd
5
3
# This program is free software; you can redistribute it and/or modify
6
4
# it under the terms of the GNU General Public License as published by
15
13
# You should have received a copy of the GNU General Public License
16
14
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
17
"""Symbol versioning tests."""
23
21
from bzrlib import symbol_versioning
22
from bzrlib.symbol_versioning import (
24
28
from bzrlib.tests import TestCase
27
@symbol_versioning.deprecated_function(symbol_versioning.zero_seven)
28
def deprecated_function():
31
@deprecated_function(deprecated_in((0, 7, 0)))
32
def sample_deprecated_function():
29
33
"""Deprecated function docstring."""
33
a_deprecated_list = symbol_versioning.deprecated_list(symbol_versioning.zero_nine,
37
a_deprecated_list = symbol_versioning.deprecated_list(deprecated_in((0, 9, 0)),
34
38
'a_deprecated_list', ['one'], extra="Don't use me")
37
41
a_deprecated_dict = symbol_versioning.DeprecatedDict(
38
symbol_versioning.zero_fourteen,
42
deprecated_in((0, 14, 0)),
39
43
'a_deprecated_dict',
41
45
advice='Pull the other one!',
51
55
super(TestDeprecationWarnings, self).setUp()
52
56
self._warnings = []
54
@symbol_versioning.deprecated_method(symbol_versioning.zero_seven)
58
@deprecated_method(deprecated_in((0, 7, 0)))
55
59
def deprecated_method(self):
56
60
"""Deprecated method docstring.
103
107
def test_deprecated_function(self):
104
108
expected_warning = (
105
"bzrlib.tests.test_symbol_versioning.deprecated_function "
109
"bzrlib.tests.test_symbol_versioning.sample_deprecated_function "
106
110
"was deprecated in version 0.7.", DeprecationWarning, 2)
107
111
expected_docstring = ('Deprecated function docstring.\n'
109
113
'This function was deprecated in version 0.7.\n'
111
115
self.check_deprecated_callable(expected_warning, expected_docstring,
112
"deprecated_function",
116
"sample_deprecated_function",
113
117
"bzrlib.tests.test_symbol_versioning",
118
sample_deprecated_function)
116
120
def test_deprecated_list(self):
117
121
expected_warning = (
203
207
'TestDeprecationWarnings.test_deprecation_string was deprecated in '
205
209
symbol_versioning.deprecation_string(
206
self.test_deprecation_string, symbol_versioning.zero_eleven))
210
self.test_deprecation_string,
211
deprecated_in((0, 11, 0))))
207
212
self.assertEqual('bzrlib.symbol_versioning.deprecated_function was '
208
213
'deprecated in version 0.11.',
209
214
symbol_versioning.deprecation_string(
210
215
symbol_versioning.deprecated_function,
211
symbol_versioning.zero_eleven))
216
deprecated_in((0, 11, 0))))
214
219
class TestSuppressAndActivate(TestCase):
217
223
existing_filters = list(warnings.filters)
219
225
warnings.filters[:] = existing_filters