ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dankil...@apache.org
Subject incubator-ariatosca git commit: fixes2
Date Wed, 30 Nov 2016 13:21:19 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-28-integrate-appveyor fb89e12c0 -> daaff6432


fixes2


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/daaff643
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/daaff643
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/daaff643

Branch: refs/heads/ARIA-28-integrate-appveyor
Commit: daaff6432f3eb785995e3a9414cabfe56766418e
Parents: fb89e12
Author: Dan Kilman <dank@gigaspaces.com>
Authored: Wed Nov 30 15:21:13 2016 +0200
Committer: Dan Kilman <dank@gigaspaces.com>
Committed: Wed Nov 30 15:21:13 2016 +0200

----------------------------------------------------------------------
 tests/test_logger.py | 65 ++++++++++++++++++++++-------------------------
 1 file changed, 31 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/daaff643/tests/test_logger.py
----------------------------------------------------------------------
diff --git a/tests/test_logger.py b/tests/test_logger.py
index 2cb87ed..0199068 100644
--- a/tests/test_logger.py
+++ b/tests/test_logger.py
@@ -14,7 +14,6 @@
 # limitations under the License.
 
 import logging
-import tempfile
 
 from aria.logger import (create_logger,
                          create_console_log_handler,
@@ -70,42 +69,40 @@ def test_create_console_log_handler(capsys):
     assert err.count(info_test_string) == 1
 
 
-def test_create_file_log_handler():
+def test_create_file_log_handler(tmpdir):
 
     test_string = 'create_file_log_test_string'
 
-    with tempfile.NamedTemporaryFile() as temp_file:
-        handler = create_file_log_handler(file_path=temp_file.name)
-        assert handler.baseFilename == temp_file.name
-        assert handler.maxBytes == 5 * 1000 * 1024
-        assert handler.backupCount == 10
-        assert handler.stream is None
-        assert handler.level == logging.DEBUG
-        assert handler.formatter == _default_file_formatter
-
-        logger = create_logger(handlers=[handler])
-        logger.debug(test_string)
-        temp_file.flush()
-        temp_file.seek(0)
-        assert test_string in temp_file.read()
-
-    with tempfile.NamedTemporaryFile() as temp_file:
-        handler = create_file_log_handler(
-            file_path=temp_file.name,
-            level=logging.INFO,
-            max_bytes=1000,
-            backup_count=2,
-            formatter=logging.Formatter()
-        )
-        assert handler.baseFilename == temp_file.name
-        assert handler.level == logging.INFO
-        assert handler.maxBytes == 1000
-        assert handler.backupCount == 2
-        assert isinstance(handler.formatter, logging.Formatter)
-
-        logger = create_logger(handlers=[handler])
-        logger.info(test_string)
-        assert test_string in temp_file.read()
+    debug_log = tmpdir.join('debug.log')
+    handler = create_file_log_handler(file_path=str(debug_log))
+    assert handler.baseFilename == str(debug_log)
+    assert handler.maxBytes == 5 * 1000 * 1024
+    assert handler.backupCount == 10
+    assert handler.stream is None
+    assert handler.level == logging.DEBUG
+    assert handler.formatter == _default_file_formatter
+
+    logger = create_logger(handlers=[handler])
+    logger.debug(test_string)
+    assert test_string in debug_log.read()
+
+    info_log = tmpdir.join('info.log')
+    handler = create_file_log_handler(
+        file_path=str(info_log),
+        level=logging.INFO,
+        max_bytes=1000,
+        backup_count=2,
+        formatter=logging.Formatter()
+    )
+    assert handler.baseFilename == str(info_log)
+    assert handler.level == logging.INFO
+    assert handler.maxBytes == 1000
+    assert handler.backupCount == 2
+    assert isinstance(handler.formatter, logging.Formatter)
+
+    logger = create_logger(handlers=[handler])
+    logger.info(test_string)
+    assert test_string in info_log.read()
 
 
 def test_loggermixin(capsys):


Mime
View raw message