Code

Ticket #14264: 14264.3.diff

File 14264.3.diff, 1.6 KB (added by metzen, 18 months ago)
Line 
1diff --git a/django/conf/__init__.py b/django/conf/__init__.py
2index 1804c85..4e6f0f9 100644
3--- a/django/conf/__init__.py
4+++ b/django/conf/__init__.py
5@@ -83,6 +83,7 @@ class LazySettings(LazyObject):
6         for name, value in options.items():
7             setattr(holder, name, value)
8         self._wrapped = holder
9+        self._configure_logging()
10 
11     @property
12     def configured(self):
13diff --git a/tests/regressiontests/logging_tests/tests.py b/tests/regressiontests/logging_tests/tests.py
14index e40800e..02d37be 100644
15--- a/tests/regressiontests/logging_tests/tests.py
16+++ b/tests/regressiontests/logging_tests/tests.py
17@@ -4,7 +4,7 @@ import copy
18 import logging
19 import warnings
20 
21-from django.conf import compat_patch_logging_config
22+from django.conf import compat_patch_logging_config, LazySettings
23 from django.core import mail
24 from django.test import TestCase, RequestFactory
25 from django.test.utils import override_settings
26@@ -302,3 +302,20 @@ class SettingsConfigTest(AdminScriptTestCase):
27         out, err = self.run_manage(['validate'])
28         self.assertNoOutput(err)
29         self.assertOutput(out, "0 errors found")
30+
31+
32+def dictConfig(config):
33+  dictConfig.called = True
34+dictConfig.called = False
35+
36+
37+class SettingsConfigureLogging(SimpleTestCase):
38+    """
39+    Test that calling settings.configure() initializes the logging
40+    configuration.
41+    """
42+    def test_configure_initializes_logging(self):
43+      settings = LazySettings()
44+      settings.configure(
45+          LOGGING_CONFIG='regressiontests.logging_tests.tests.dictConfig')
46+      self.assertTrue(dictConfig.called)