summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-01-07 18:49:02 -0500
committerTim Graham <timograham@gmail.com>2015-01-08 09:09:24 -0500
commit557c514f900b1280cfd4a892be893dd4c338ae74 (patch)
treea768a8153223b7b32a2af653781884abd6de45b1
parent5e18f6f724dda3f6462c92f825b31b2e423f4e7c (diff)
[1.7.x] Fixed #24095 -- Prevented WarningLoggerTests from leaking a warnings filter.
Backport of ade985999657eaef6a9510c2aeba9b2196d7bf6e from master
-rw-r--r--tests/logging_tests/tests.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py
index d840225727..2a28abdc22 100644
--- a/tests/logging_tests/tests.py
+++ b/tests/logging_tests/tests.py
@@ -120,14 +120,18 @@ class WarningLoggerTests(TestCase):
@override_settings(DEBUG=True)
def test_warnings_capture(self):
- warnings.warn('Foo Deprecated', RemovedInNextVersionWarning)
- output = force_text(self.outputs[0].getvalue())
- self.assertTrue('Foo Deprecated' in output)
+ with warnings.catch_warnings():
+ warnings.filterwarnings('always')
+ warnings.warn('Foo Deprecated', RemovedInNextVersionWarning)
+ output = force_text(self.outputs[0].getvalue())
+ self.assertTrue('Foo Deprecated' in output)
def test_warnings_capture_debug_false(self):
- warnings.warn('Foo Deprecated', RemovedInNextVersionWarning)
- output = force_text(self.outputs[0].getvalue())
- self.assertFalse('Foo Deprecated' in output)
+ with warnings.catch_warnings():
+ warnings.filterwarnings('always')
+ warnings.warn('Foo Deprecated', RemovedInNextVersionWarning)
+ output = force_text(self.outputs[0].getvalue())
+ self.assertNotIn('Foo Deprecated', output)
@override_settings(DEBUG=True)
def test_error_filter_still_raises(self):