[test] Add basic logger test

pull/2/head
Daniel Van Der Maden 5 years ago
parent e53c48963f
commit 6a3575d0a9
  1. 20
      tests/logging-pyhmy/test_logging.py

@ -6,10 +6,26 @@ from pyhmy import logging
def test_basic_logger():
logger = logging.ControlledLogger("test", "logs/")
if os.path.exists(f"{os.getcwd()}/logs/pytest.log"):
os.remove(f"{os.getcwd()}/logs/pytest.log")
logger = logging.ControlledLogger("pytest", "logs/")
assert os.path.exists(f"{os.getcwd()}/logs/pytest.log")
logger.info("test info")
logger.debug("test debug")
logger.error("test error")
logger.warning("test warning")
with open(f"{os.getcwd()}/logs/pytest.log", 'r') as f:
log_file_contents = f.readlines()
assert not log_file_contents
logger.write()
# TODO: finish this test
with open(f"{os.getcwd()}/logs/pytest.log", 'r') as f:
log_file_contents = f.readlines()
for line in log_file_contents:
if "INFO" in line:
assert "test info" in line
if "DEBUG" in line:
assert "test debug" in line
if "WARNING" in line:
assert "test warning" in line
if "ERROR" in line:
assert "test error" in line

Loading…
Cancel
Save