[1.5.x] Fixed #14264 -- Ensured settings.configure configures logging

Thanks Matt McDonald for the patch.
Backport of 34162698c from master.
This commit is contained in:
Claude Paroz 2012-11-10 12:05:58 +01:00
parent 6554137eeb
commit e6bc0c5bab
2 changed files with 19 additions and 1 deletions

View File

@ -83,6 +83,7 @@ class LazySettings(LazyObject):
for name, value in options.items():
setattr(holder, name, value)
self._wrapped = holder
self._configure_logging()
@property
def configured(self):

View File

@ -4,7 +4,7 @@ import copy
import logging
import warnings
from django.conf import compat_patch_logging_config
from django.conf import compat_patch_logging_config, LazySettings
from django.core import mail
from django.test import TestCase, RequestFactory
from django.test.utils import override_settings
@ -302,3 +302,20 @@ class SettingsConfigTest(AdminScriptTestCase):
out, err = self.run_manage(['validate'])
self.assertNoOutput(err)
self.assertOutput(out, "0 errors found")
def dictConfig(config):
dictConfig.called = True
dictConfig.called = False
class SettingsConfigureLogging(TestCase):
"""
Test that calling settings.configure() initializes the logging
configuration.
"""
def test_configure_initializes_logging(self):
settings = LazySettings()
settings.configure(
LOGGING_CONFIG='regressiontests.logging_tests.tests.dictConfig')
self.assertTrue(dictConfig.called)