~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_symbol_versioning.py

  • Committer: Martin Pool
  • Date: 2009-07-10 06:46:10 UTC
  • mto: (4525.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4526.
  • Revision ID: mbp@sourcefrog.net-20090710064610-sqviksbqp5i34sw2
Rename to per_interrepository

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009 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
76
76
        expected_warning = (
77
77
            "bzrlib.tests.test_symbol_versioning."
78
78
            "deprecated_static "
79
 
            "was deprecated in version 0.7.0.", DeprecationWarning, 2)
 
79
            "was deprecated in version 0.7.", DeprecationWarning, 2)
80
80
        expected_docstring = (
81
81
            'Deprecated static.\n'
82
82
            '\n'
83
 
            'This function was deprecated in version 0.7.0.\n'
 
83
            'This function was deprecated in version 0.7.\n'
84
84
            )
85
85
        self.check_deprecated_callable(
86
86
            expected_warning, expected_docstring,
92
92
        expected_warning = (
93
93
            "bzrlib.tests.test_symbol_versioning."
94
94
            "TestDeprecationWarnings.deprecated_method "
95
 
            "was deprecated in version 0.7.0.", DeprecationWarning, 2)
96
 
        expected_docstring = (
97
 
            'Deprecated method docstring.\n'
98
 
            '\n'
99
 
            '        This might explain stuff.\n'
100
 
            '        \n'
101
 
            '        This method was deprecated in version 0.7.0.\n'
102
 
            '        ')
 
95
            "was deprecated in version 0.7.", DeprecationWarning, 2)
 
96
        expected_docstring = ('Deprecated method docstring.\n'
 
97
                              '\n'
 
98
                              '        This might explain stuff.\n'
 
99
                              '        \n'
 
100
                              '        This method was deprecated in version 0.7.\n'
 
101
                              '        ')
103
102
        self.check_deprecated_callable(expected_warning, expected_docstring,
104
103
                                       "deprecated_method",
105
104
                                       "bzrlib.tests.test_symbol_versioning",
108
107
    def test_deprecated_function(self):
109
108
        expected_warning = (
110
109
            "bzrlib.tests.test_symbol_versioning.sample_deprecated_function "
111
 
            "was deprecated in version 0.7.0.", DeprecationWarning, 2)
 
110
            "was deprecated in version 0.7.", DeprecationWarning, 2)
112
111
        expected_docstring = ('Deprecated function docstring.\n'
113
112
                              '\n'
114
 
                              'This function was deprecated in version 0.7.0.\n'
 
113
                              'This function was deprecated in version 0.7.\n'
115
114
                              )
116
115
        self.check_deprecated_callable(expected_warning, expected_docstring,
117
116
                                       "sample_deprecated_function",
120
119
 
121
120
    def test_deprecated_list(self):
122
121
        expected_warning = (
123
 
            "Modifying a_deprecated_list was deprecated in version 0.9.0."
 
122
            "Modifying a_deprecated_list was deprecated in version 0.9."
124
123
            " Don't use me", DeprecationWarning, 3)
125
124
        old_warning_method = symbol_versioning.warn
126
125
        try:
158
157
 
159
158
    def test_deprecated_dict(self):
160
159
        expected_warning = (
161
 
            "access to a_deprecated_dict was deprecated in version 0.14.0."
 
160
            "access to a_deprecated_dict was deprecated in version 0.14."
162
161
            " Pull the other one!", DeprecationWarning, 2)
163
162
        old_warning_method = symbol_versioning.warn
164
163
        try:
179
178
    def check_deprecated_callable(self, expected_warning, expected_docstring,
180
179
                                  expected_name, expected_module,
181
180
                                  deprecated_callable):
182
 
        if __doc__ is None:
183
 
            # With -OO the docstring should just be the deprecated version
184
 
            expected_docstring = expected_docstring.split('\n')[-2].lstrip()
185
181
        old_warning_method = symbol_versioning.warn
186
182
        try:
187
183
            symbol_versioning.set_warning_method(self.capture_warning)
209
205
        """We can get a deprecation string for a method or function."""
210
206
        self.assertEqual('bzrlib.tests.test_symbol_versioning.'
211
207
            'TestDeprecationWarnings.test_deprecation_string was deprecated in '
212
 
            'version 0.11.0.',
 
208
            'version 0.11.',
213
209
            symbol_versioning.deprecation_string(
214
210
            self.test_deprecation_string,
215
211
            deprecated_in((0, 11, 0))))
216
212
        self.assertEqual('bzrlib.symbol_versioning.deprecated_function was '
217
 
            'deprecated in version 0.11.0.',
 
213
            'deprecated in version 0.11.',
218
214
            symbol_versioning.deprecation_string(
219
215
                symbol_versioning.deprecated_function,
220
216
                deprecated_in((0, 11, 0))))
241
237
        symbol_versioning.suppress_deprecation_warnings()
242
238
        self.assertFirstWarning('ignore', DeprecationWarning)
243
239
 
244
 
    def test_set_restore_filters(self):
245
 
        original_filters = warnings.filters[:]
246
 
        symbol_versioning.suppress_deprecation_warnings()()
247
 
        self.assertEqual(original_filters, warnings.filters)
248
 
 
249
240
    def test_suppress_deprecation_with_warning_filter(self):
250
241
        """don't suppress if we already have a filter"""
251
242
        warnings.filterwarnings('error', category=Warning)