Commit 557c514f authored by Tim Graham's avatar Tim Graham
Browse files

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

Backport of ade98599 from master
parent 5e18f6f7
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -120,14 +120,18 @@ class WarningLoggerTests(TestCase):

    @override_settings(DEBUG=True)
    def test_warnings_capture(self):
        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):
        with warnings.catch_warnings():
            warnings.filterwarnings('always')
            warnings.warn('Foo Deprecated', RemovedInNextVersionWarning)
            output = force_text(self.outputs[0].getvalue())
        self.assertFalse('Foo Deprecated' in output)
            self.assertNotIn('Foo Deprecated', output)

    @override_settings(DEBUG=True)
    def test_error_filter_still_raises(self):