diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-09-24 22:11:42 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-09-24 22:12:45 +0200 |
| commit | fc69fff9ab5bba8a6cff3eaf51f02a3204b1c015 (patch) | |
| tree | c8ef89d4346f70b560d952f4aca168135ae6d5bc /tests | |
| parent | e72e22e518a730cd28cd68c9374fa79a45e27a9c (diff) | |
Fixed #14861 -- Moved logging config outside of Settings.__init__
Thanks donspaulding for the report and simonpercivall for the
initial patch.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/logging_tests/logconfig.py | 7 | ||||
| -rw-r--r-- | tests/regressiontests/logging_tests/tests.py | 29 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/regressiontests/logging_tests/logconfig.py b/tests/regressiontests/logging_tests/logconfig.py new file mode 100644 index 0000000000..8524aa2c24 --- /dev/null +++ b/tests/regressiontests/logging_tests/logconfig.py @@ -0,0 +1,7 @@ +import logging + +from django.conf import settings + +class MyHandler(logging.Handler): + def __init__(self, *args, **kwargs): + self.config = settings.LOGGING diff --git a/tests/regressiontests/logging_tests/tests.py b/tests/regressiontests/logging_tests/tests.py index f444e0ff46..a54b425f67 100644 --- a/tests/regressiontests/logging_tests/tests.py +++ b/tests/regressiontests/logging_tests/tests.py @@ -10,6 +10,8 @@ from django.test import TestCase, RequestFactory from django.test.utils import override_settings from django.utils.log import CallbackFilter, RequireDebugFalse +from ..admin_scripts.tests import AdminScriptTestCase + # logging config prior to using filter with mail_admins OLD_LOGGING = { @@ -253,3 +255,30 @@ class AdminEmailHandlerTest(TestCase): self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outbox[0].subject, expected_subject) + + +class SettingsConfigTest(AdminScriptTestCase): + """ + Test that accessing settings in a custom logging handler does not trigger + a circular import error. + """ + def setUp(self): + log_config = """{ + 'version': 1, + 'handlers': { + 'custom_handler': { + 'level': 'INFO', + 'class': 'logging_tests.logconfig.MyHandler', + } + } +}""" + self.write_settings('settings.py', sdict={'LOGGING': log_config}) + + def tearDown(self): + self.remove_settings('settings.py') + + def test_circular_dependency(self): + # validate is just an example command to trigger settings configuration + out, err = self.run_manage(['validate']) + self.assertNoOutput(err) + self.assertOutput(out, "0 errors found") |
