Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Fixed logging-related test failure introduced by e79b857.

Backport of 654d8e9.
  • Loading branch information...
commit 9a41045b77c05ea62c49e1bd6f29ebbee7f36954 1 parent 87f4860
Jacob Kaplan-Moss authored March 27, 2013
9  tests/regressiontests/logging_tests/tests.py
@@ -142,6 +142,12 @@ class WarningLoggerTests(TestCase):
142 142
     and captured to the logging system
143 143
     """
144 144
     def setUp(self):
  145
+        # If tests are invoke with "-Wall" (or any -W flag actually) then
  146
+        # warning logging gets disabled (see django/conf/__init__.py). However,
  147
+        # these tests expect warnings to be logged, so manually force warnings
  148
+        # to the logs.
  149
+        logging.captureWarnings(True)
  150
+
145 151
         # this convoluted setup is to avoid printing this deprecation to
146 152
         # stderr during test running - as the test runner forces deprecations
147 153
         # to be displayed at the global py.warnings level
@@ -157,6 +163,9 @@ def tearDown(self):
157 163
         for i, handler in enumerate(self.logger.handlers):
158 164
             self.logger.handlers[i].stream = self.old_streams[i]
159 165
 
  166
+        # Reset warnings state.
  167
+        logging.captureWarnings(False)
  168
+
160 169
     @override_settings(DEBUG=True)
161 170
     def test_warnings_capture(self):
162 171
         warnings.warn('Foo Deprecated', DeprecationWarning)

0 notes on commit 9a41045

Please sign in to comment.
Something went wrong with that request. Please try again.