summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2013-01-31 14:56:26 -0300
committerRamiro Morales <cramm0@gmail.com>2013-01-31 14:57:45 -0300
commit7947c9e3a6bd8c1dfe7fc209fb2256a528149bb6 (patch)
treeaaec5644d25ad799fd7f4c3d5d9482933aeb9f20 /tests
parent9a4a1ce323237d0aadafbddcd270c47be251bac2 (diff)
Deprecated undocumented warnings manipulation testing tools.
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/test_utils/tests.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py
index d5d49b2104..2a74b95ffa 100644
--- a/tests/regressiontests/test_utils/tests.py
+++ b/tests/regressiontests/test_utils/tests.py
@@ -220,24 +220,27 @@ class SaveRestoreWarningState(TestCase):
# of save_warnings_state/restore_warnings_state (e.g. just
# warnings.resetwarnings()) , but it is difficult to test more.
import warnings
- self.save_warnings_state()
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
- class MyWarning(Warning):
- pass
+ self.save_warnings_state()
+
+ class MyWarning(Warning):
+ pass
- # Add a filter that causes an exception to be thrown, so we can catch it
- warnings.simplefilter("error", MyWarning)
- self.assertRaises(Warning, lambda: warnings.warn("warn", MyWarning))
+ # Add a filter that causes an exception to be thrown, so we can catch it
+ warnings.simplefilter("error", MyWarning)
+ self.assertRaises(Warning, lambda: warnings.warn("warn", MyWarning))
- # Now restore.
- self.restore_warnings_state()
- # After restoring, we shouldn't get an exception. But we don't want a
- # warning printed either, so we have to silence the warning.
- warnings.simplefilter("ignore", MyWarning)
- warnings.warn("warn", MyWarning)
+ # Now restore.
+ self.restore_warnings_state()
+ # After restoring, we shouldn't get an exception. But we don't want a
+ # warning printed either, so we have to silence the warning.
+ warnings.simplefilter("ignore", MyWarning)
+ warnings.warn("warn", MyWarning)
- # Remove the filter we just added.
- self.restore_warnings_state()
+ # Remove the filter we just added.
+ self.restore_warnings_state()
class HTMLEqualTests(TestCase):