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
commite6537dfbd2594a83e30538e321b7db4ce9f61b5a (patch)
tree2ae4209d41d349951947af3ae732c58947e6c87c
parentd01ff113e96fc2bf6473de331b6ed2c363ed5acd (diff)
downloadlogutils-git-e6537dfbd2594a83e30538e321b7db4ce9f61b5a.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