Skip to content

Commit

Permalink
[1.7.x] Fixed #24095 -- Prevented WarningLoggerTests from leaking a w…
Browse files Browse the repository at this point in the history
…arnings filter.

Backport of ade9859 from master
  • Loading branch information
timgraham committed Jan 8, 2015
1 parent 5e18f6f commit 557c514
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/logging_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,18 @@ def tearDown(self):

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

0 comments on commit 557c514

Please sign in to comment.