~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_symbol_versioning.py

  • Committer: Wouter van Heyst
  • Date: 2012-01-25 21:13:15 UTC
  • mto: (6437.3.27 2.5)
  • mto: This revision was merged to the branch mainline in revision 6451.
  • Revision ID: larstiq@larstiq.dyndns.org-20120125211315-ch74doua37bqet0i
mechanically replace file().write() pattern with a with-keyword version

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)
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)