summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Young <liam.young@canonical.com>2014-07-16 12:21:17 +0100
committerLiam Young <liam.young@canonical.com>2014-07-16 12:21:17 +0100
commitcf7630a2ec8e9b81f82949545f949e3e05028a26 (patch)
treec3d14ae784d79601ec8fd84d863fd9847e3ef1ab
parent0524c20ed378adfdd1bcb82b344e8833a5325e4a (diff)
downloadlogutils-cf7630a2ec8e9b81f82949545f949e3e05028a26.tar.gz
Ensure compatibility of tests with Python 3
-rw-r--r--tests/test_dictconfig.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/test_dictconfig.py b/tests/test_dictconfig.py
index bf2ce11..e53bf5b 100644
--- a/tests/test_dictconfig.py
+++ b/tests/test_dictconfig.py
@@ -27,6 +27,12 @@ def testHandler():
def handlerFunc():
return logging.StreamHandler()
+def is_python2():
+ if sys.version_info >= (2, 0) and sys.version_info < (3, 0):
+ return True
+ else:
+ return False
+
class CustomHandler(logging.StreamHandler):
pass
@@ -44,7 +50,8 @@ class ConfigDictTest(unittest.TestCase):
self.saved_handlers = logging._handlers.copy()
self.saved_handler_list = logging._handlerList[:]
self.saved_loggers = logger_dict.copy()
- self.saved_level_names = logging._levelNames.copy()
+ if is_python2():
+ self.saved_level_names = logging._levelNames.copy()
finally:
logging._releaseLock()
@@ -56,8 +63,9 @@ class ConfigDictTest(unittest.TestCase):
self.root_logger.setLevel(self.original_logging_level)
logging._acquireLock()
try:
- logging._levelNames.clear()
- logging._levelNames.update(self.saved_level_names)
+ if is_python2():
+ logging._levelNames.clear()
+ logging._levelNames.update(self.saved_level_names)
logging._handlers.clear()
logging._handlers.update(self.saved_handlers)
logging._handlerList[:] = self.saved_handler_list