Module: check_mk
Branch: master
Commit: e2e1da81f81cc3dbe307e0b39ff3674f0ff51ddb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e2e1da81f81cc3…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Nov 26 13:43:24 2018 +0100
Fixed log unit tests confusing the cmk.log.logger
All trys to write logs to the cmk.log default logger resulted in
a ValueError exception like this:
---
Traceback (most recent call last):
File "/usr/lib/python2.7/logging/__init__.py", line 872, in emit
stream.write(ufs % msg)
File
"/home/lm/git/check_mk/.venv/local/lib/python2.7/site-packages/py/_io/capture.py",
line 16, in write
StringIO.write(self, data)
ValueError: I/O operation on closed file
Logged from file ldap_connector.py, line 579
---
Change-Id: Ieeb8655641e8fe7024a8d7c8ce2260b258734eec
---
tests/unit/cmk/test_log.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tests/unit/cmk/test_log.py b/tests/unit/cmk/test_log.py
index 9776d7a..7719f55 100644
--- a/tests/unit/cmk/test_log.py
+++ b/tests/unit/cmk/test_log.py
@@ -1,6 +1,7 @@
import pytest
import cmk.log
+
def test_get_logger():
l = cmk.log.get_logger("asd")
assert l.name == "cmk.asd"
@@ -25,6 +26,9 @@ def test_setup_console_logging(capsys):
l = cmk.log.get_logger("test")
l.info("test123")
+ # Cleanup handler registered with cmk.log.setup_console_logging()
+ cmk.log.logger.handlers.pop()
+
out, err = capsys.readouterr()
assert out == "test123\n"
assert err == ""