Rev 5321: The symbol_versioning module can now cleanup after itself - in http://bazaar.launchpad.net/~lifeless/bzr/globalzapping
Robert Collins
robertc at robertcollins.net
Fri Jun 25 07:11:27 BST 2010
At http://bazaar.launchpad.net/~lifeless/bzr/globalzapping
------------------------------------------------------------
revno: 5321
revision-id: robertc at robertcollins.net-20100625061121-0cx949gxhae5aeib
parent: pqm at pqm.ubuntu.com-20100625042410-r2zawge1wxx9ma9p
committer: Robert Collins <robertc at robertcollins.net>
branch nick: globalzapping
timestamp: Fri 2010-06-25 16:11:21 +1000
message:
The symbol_versioning module can now cleanup after itself -
``suppress_deprecation_warnings`` now returns a cleanup function.
(Robert Collins)
=== modified file 'NEWS'
--- a/NEWS 2010-06-25 04:24:10 +0000
+++ b/NEWS 2010-06-25 06:11:21 +0000
@@ -179,6 +179,10 @@
* Improved ``bzrlib.urlutils`` to handle lp:foo/bar URLs. (Gordon Tyler)
+* The symbol_versioning module can now cleanup after itself -
+ ``suppress_deprecation_warnings`` now returns a cleanup function.
+ (Robert Collins)
+
Testing
*******
=== modified file 'bzrlib/symbol_versioning.py'
--- a/bzrlib/symbol_versioning.py 2009-09-15 02:28:34 +0000
+++ b/bzrlib/symbol_versioning.py 2010-06-25 06:11:21 +0000
@@ -314,6 +314,7 @@
:param override: If True, always set the ignore, if False, only set the
ignore if there isn't already a filter.
+ :return: A callable to remove the new warnings this added.
"""
import warnings
if not override and _check_for_filter(error_only=False):
@@ -321,6 +322,10 @@
# then skip it.
return
warnings.filterwarnings('ignore', category=DeprecationWarning)
+ filter = warnings.filters[0]
+ def cleanup():
+ warnings.filters.remove(filter)
+ return cleanup
def activate_deprecation_warnings(override=True):
=== modified file 'bzrlib/tests/test_symbol_versioning.py'
--- a/bzrlib/tests/test_symbol_versioning.py 2010-04-23 08:51:52 +0000
+++ b/bzrlib/tests/test_symbol_versioning.py 2010-06-25 06:11:21 +0000
@@ -241,6 +241,11 @@
symbol_versioning.suppress_deprecation_warnings()
self.assertFirstWarning('ignore', DeprecationWarning)
+ def test_set_restore_filters(self):
+ original_filters = warnings.filters[:]
+ symbol_versioning.suppress_deprecation_warnings()()
+ self.assertEqual(original_filters, warnings.filters)
+
def test_suppress_deprecation_with_warning_filter(self):
"""don't suppress if we already have a filter"""
warnings.filterwarnings('error', category=Warning)
More information about the bazaar-commits
mailing list