[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:
parent
6554137eeb
commit
e6bc0c5bab
|
@ -83,6 +83,7 @@ class LazySettings(LazyObject):
|
||||||
for name, value in options.items():
|
for name, value in options.items():
|
||||||
setattr(holder, name, value)
|
setattr(holder, name, value)
|
||||||
self._wrapped = holder
|
self._wrapped = holder
|
||||||
|
self._configure_logging()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def configured(self):
|
def configured(self):
|
||||||
|
|
|
@ -4,7 +4,7 @@ import copy
|
||||||
import logging
|
import logging
|
||||||
import warnings
|
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.core import mail
|
||||||
from django.test import TestCase, RequestFactory
|
from django.test import TestCase, RequestFactory
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
|
@ -302,3 +302,20 @@ class SettingsConfigTest(AdminScriptTestCase):
|
||||||
out, err = self.run_manage(['validate'])
|
out, err = self.run_manage(['validate'])
|
||||||
self.assertNoOutput(err)
|
self.assertNoOutput(err)
|
||||||
self.assertOutput(out, "0 errors found")
|
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)
|
||||||
|
|
Loading…
Reference in New Issue