summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-04-28 03:12:40 +0000
committerGerrit Code Review <review@openstack.org>2013-04-28 03:12:40 +0000
commitf8ef97d6b14ecf425e92034449a3743b42829009 (patch)
treebf7f4fa73f229ae36edfe3a42b4e8faa1c67f1f1 /tests
parente79811464cdab63b12e140d4d7a9ec650ddcc3e0 (diff)
parent465e27158725b6b262e251247bc60edaeda2f54d (diff)
downloadoslo-f8ef97d6b14ecf425e92034449a3743b42829009.tar.gz
oslo-f8ef97d6b14ecf425e92034449a3743b42829009.tar.xz
oslo-f8ef97d6b14ecf425e92034449a3743b42829009.zip
Merge "Support for lazily instantiated loggers"
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_log.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/unit/test_log.py b/tests/unit/test_log.py
index 4241e2e..a80b872 100644
--- a/tests/unit/test_log.py
+++ b/tests/unit/test_log.py
@@ -20,17 +20,20 @@ def _fake_context():
return context.RequestContext(1, 1)
-class LoggerTestCase(test_utils.BaseTestCase):
+class CommonLoggerTestsMixIn(object):
+ """These tests are shared between LoggerTestCase and
+ LazyLoggerTestCase.
+ """
+
def setUp(self):
- super(LoggerTestCase, self).setUp()
+ super(CommonLoggerTestsMixIn, self).setUp()
# common context has different fields to the defaults in log.py
self.config(logging_context_format_string='%(asctime)s %(levelname)s '
'%(name)s [%(request_id)s '
'%(user)s %(tenant)s] '
'%(message)s')
-
- self.log = log.getLogger()
+ self.log = None
def test_handlers_have_legacy_formatter(self):
formatters = []
@@ -73,6 +76,18 @@ class LoggerTestCase(test_utils.BaseTestCase):
self.assertRaises(AttributeError, getattr, log, func)
+class LoggerTestCase(CommonLoggerTestsMixIn, test_utils.BaseTestCase):
+ def setUp(self):
+ super(LoggerTestCase, self).setUp()
+ self.log = log.getLogger()
+
+
+class LazyLoggerTestCase(CommonLoggerTestsMixIn, test_utils.BaseTestCase):
+ def setUp(self):
+ super(LazyLoggerTestCase, self).setUp()
+ self.log = log.getLazyLogger()
+
+
class LogHandlerTestCase(test_utils.BaseTestCase):
def test_log_path_logdir(self):
self.config(log_dir='/some/path', log_file=None)