From 9410cfbb893e1d2a220afd34407713768d63cd71 Mon Sep 17 00:00:00 2001 From: Svend Vanderveken Date: Tue, 8 Dec 2015 13:32:22 +0100 Subject: [PATCH] adding one UT for log_to_stdout --- tests/core.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/core.py b/tests/core.py index 2227600f9cafd..64470f6780cf8 100644 --- a/tests/core.py +++ b/tests/core.py @@ -398,6 +398,23 @@ def test_parameterized_config_gen(self): assert "{AIRFLOW_HOME}" not in cfg assert "{FERNET_KEY}" not in cfg + def test_calling_log_to_stdout_should_add_one_stream_handler(self): + + # first resetting the logger + root_logger = logging.getLogger() + for handler in root_logger.handlers: + root_logger.removeHandler(handler) + + root_logger.setLevel(logging.NOTSET) + assert root_logger.level == logging.NOTSET + + utils.log_to_stdout() + stream_handlers = [h for h in root_logger.handlers + if isinstance(h, logging.StreamHandler)] + + assert len(stream_handlers) == 1 + assert root_logger.level == utils.LOGGING_LEVEL + def test_calling_log_to_stdout_2X_should_add_only_one_stream_handler(self): utils.log_to_stdout()