Add tests for console logging (test_island_logger.py)

This commit is contained in:
Shreya 2021-05-11 19:06:38 +05:30
parent c5ba48db53
commit 5f8145e3d1
1 changed files with 28 additions and 0 deletions

View File

@ -36,3 +36,31 @@ def test_setup_logging_log_level_info(tmpdir):
with open(LOG_FILE, "r") as f:
line = f.readline()
assert TEST_STRING not in line
def test_setup_logging_console_log_level_debug(capsys, tmpdir):
DATA_DIR = tmpdir
LOG_LEVEL = "DEBUG"
TEST_STRING = "Hello, Monkey! (Log level: debug)"
setup_logging(DATA_DIR, LOG_LEVEL)
logger = logging.getLogger("TestLogger")
logger.debug(TEST_STRING)
captured = capsys.readouterr()
assert TEST_STRING in captured.out
def test_setup_logging_console_log_level_info(capsys, tmpdir):
DATA_DIR = tmpdir
LOG_LEVEL = "INFO"
TEST_STRING = "Hello, Monkey! (Log level: info)"
setup_logging(DATA_DIR, LOG_LEVEL)
logger = logging.getLogger("TestLogger")
logger.debug(TEST_STRING)
captured = capsys.readouterr()
assert TEST_STRING not in captured.out