1
0
mirror of https://github.com/django/django.git synced 2025-10-30 09:06:13 +00:00

[1.7.x] Fixed #24095 -- Prevented WarningLoggerTests from leaking a warnings filter.

Backport of ade9859996 from master
This commit is contained in:
Tim Graham
2015-01-07 18:49:02 -05:00
parent 5e18f6f724
commit 557c514f90

View File

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