summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2013-03-27 12:05:31 -0500
committerJacob Kaplan-Moss <jacob@jacobian.org>2013-03-27 12:21:26 -0500
commit9a41045b77c05ea62c49e1bd6f29ebbee7f36954 (patch)
treedfbde2977cdd992dcef79e756aee96dd3f38cecd
parent87f48607184ca3688ad1c0376aa0bfe27668c63b (diff)
[1.5.x] Fixed logging-related test failure introduced by e79b857.
Backport of 654d8e9.
-rw-r--r--tests/regressiontests/logging_tests/tests.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/regressiontests/logging_tests/tests.py b/tests/regressiontests/logging_tests/tests.py
index a498510cfe..35968066bc 100644
--- a/tests/regressiontests/logging_tests/tests.py
+++ b/tests/regressiontests/logging_tests/tests.py
@@ -142,6 +142,12 @@ class WarningLoggerTests(TestCase):
and captured to the logging system
"""
def setUp(self):
+ # If tests are invoke with "-Wall" (or any -W flag actually) then
+ # warning logging gets disabled (see django/conf/__init__.py). However,
+ # these tests expect warnings to be logged, so manually force warnings
+ # to the logs.
+ logging.captureWarnings(True)
+
# this convoluted setup is to avoid printing this deprecation to
# stderr during test running - as the test runner forces deprecations
# to be displayed at the global py.warnings level
@@ -157,6 +163,9 @@ class WarningLoggerTests(TestCase):
for i, handler in enumerate(self.logger.handlers):
self.logger.handlers[i].stream = self.old_streams[i]
+ # Reset warnings state.
+ logging.captureWarnings(False)
+
@override_settings(DEBUG=True)
def test_warnings_capture(self):
warnings.warn('Foo Deprecated', DeprecationWarning)