Beispiel #1
0
def test_setup_logger():
    with tempfile.NamedTemporaryFile('r') as tmpfile:
        with utils.AsyncLoggingHandler(tmpfile.name) as log_handler:
            logger = utils.setup_logger("test", utils.LogLevel.info, log_handler)
            logger.info("Hello World!")
            time.sleep(1)
            assert "Hello World!" in tmpfile.read()
Beispiel #2
0
def test_setup_logger_stderr(capsys):
    with utils.AsyncLoggingHandler() as log_handler:
        logger = utils.setup_logger("test", utils.LogLevel.info, log_handler)
        logger.info("Hello World!")
        time.sleep(1)
        captured = capsys.readouterr()
        assert "Hello World!" in captured.err