~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_symbol_versioning.py

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 05:06:57 UTC
  • mfrom: (6603.4.1 bzr)
  • Revision ID: pqm@pqm.ubuntu.com-20160421050657-ygnzfybewvudf1j9
(richard-wilbur) Use initial_comment as commit_message for lp_propose.(Shawn
 Wang) (Shawn Wang)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009 Canonical Ltd
 
1
# Copyright (C) 2006-2011 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
22
22
from bzrlib.symbol_versioning import (
23
23
    deprecated_function,
24
24
    deprecated_in,
25
 
    deprecated_list,
26
25
    deprecated_method,
27
26
    )
28
27
from bzrlib.tests import TestCase
179
178
    def check_deprecated_callable(self, expected_warning, expected_docstring,
180
179
                                  expected_name, expected_module,
181
180
                                  deprecated_callable):
 
181
        if __doc__ is None:
 
182
            # With -OO the docstring should just be the deprecated version
 
183
            expected_docstring = expected_docstring.split('\n')[-2].lstrip()
182
184
        old_warning_method = symbol_versioning.warn
183
185
        try:
184
186
            symbol_versioning.set_warning_method(self.capture_warning)
220
222
class TestSuppressAndActivate(TestCase):
221
223
 
222
224
    def setUp(self):
223
 
        TestCase.setUp(self)
 
225
        super(TestSuppressAndActivate, self).setUp()
224
226
        existing_filters = list(warnings.filters)
225
227
        def restore():
226
228
            warnings.filters[:] = existing_filters
238
240
        symbol_versioning.suppress_deprecation_warnings()
239
241
        self.assertFirstWarning('ignore', DeprecationWarning)
240
242
 
 
243
    def test_set_restore_filters(self):
 
244
        original_filters = warnings.filters[:]
 
245
        symbol_versioning.suppress_deprecation_warnings()()
 
246
        self.assertEqual(original_filters, warnings.filters)
 
247
 
241
248
    def test_suppress_deprecation_with_warning_filter(self):
242
249
        """don't suppress if we already have a filter"""
243
250
        warnings.filterwarnings('error', category=Warning)