Kaydet (Commit) 15c3906e authored tarafından Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss

Merge pull request #968 from jacobian/fix-warning-log-regression

Fixed logging-related test failure introduced by e79b857a.
...@@ -93,6 +93,12 @@ class WarningLoggerTests(TestCase): ...@@ -93,6 +93,12 @@ class WarningLoggerTests(TestCase):
and captured to the logging system and captured to the logging system
""" """
def setUp(self): 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 # this convoluted setup is to avoid printing this deprecation to
# stderr during test running - as the test runner forces deprecations # stderr during test running - as the test runner forces deprecations
# to be displayed at the global py.warnings level # to be displayed at the global py.warnings level
...@@ -108,6 +114,9 @@ class WarningLoggerTests(TestCase): ...@@ -108,6 +114,9 @@ class WarningLoggerTests(TestCase):
for i, handler in enumerate(self.logger.handlers): for i, handler in enumerate(self.logger.handlers):
self.logger.handlers[i].stream = self.old_streams[i] self.logger.handlers[i].stream = self.old_streams[i]
# Reset warnings state.
logging.captureWarnings(False)
@override_settings(DEBUG=True) @override_settings(DEBUG=True)
def test_warnings_capture(self): def test_warnings_capture(self):
warnings.warn('Foo Deprecated', DeprecationWarning) warnings.warn('Foo Deprecated', DeprecationWarning)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment