diff --git a/tests/core/test_logging.py b/tests/core/test_logging.py index bef33b7..d5540df 100644 --- a/tests/core/test_logging.py +++ b/tests/core/test_logging.py @@ -19,14 +19,17 @@ def _reset_logging(): logging.shutdown() reload(logging) + pytest.mark.usefixtures = _reset_logging logger_name = "tests" + @pytest.fixture() def handler(): return MozlogHandler(name=logger_name) + @pytest.fixture() def formatter(): return MozlogFormatter(logger_name=logger_name) @@ -69,6 +72,7 @@ class = dockerflow.logging.MozlogHandler assert logger.handlers[0].logger_name == "tests" assert isinstance(logger.handlers[0].formatter, MozlogFormatter) + def test_set_logger_name_through_handler(caplog): handler = MozlogHandler(name="logger_name_handler") logger = logging.getLogger("test") @@ -77,6 +81,7 @@ def test_set_logger_name_through_handler(caplog): [record] = caplog.records record.logger_name = "logger_name_handler" + def test_set_logger_name_through_formatter(caplog): handler = logging.StreamHandler() formatter = MozlogFormatter(logger_name="logger_name_formatter") @@ -89,6 +94,7 @@ def test_set_logger_name_through_formatter(caplog): [record] = caplog.records record.logger_name = "logger_name_formatter" + def test_handler_precedence_logger_name(caplog): handler = MozlogHandler(name="logger_name_handler") formatter = MozlogFormatter(logger_name="logger_name_formatter") @@ -101,6 +107,7 @@ def test_handler_precedence_logger_name(caplog): [record] = caplog.records record.logger_name = "logger_name_handler" + def test_basic_operation(caplog, handler, formatter): """Ensure log formatter contains all the expected fields and values""" message_text = "simple test" @@ -118,6 +125,7 @@ def test_basic_operation(caplog, handler, formatter): assert details["EnvVersion"] == formatter.LOGGING_FORMAT_VERSION assert details["Fields"]["msg"] == message_text + def test_custom_paramters(caplog, handler, formatter): """Ensure log formatter can handle custom parameters""" logger = logging.getLogger("tests.test_logging") diff --git a/tests/fastapi/test_fastapi.py b/tests/fastapi/test_fastapi.py index 8453c20..9a5b98a 100644 --- a/tests/fastapi/test_fastapi.py +++ b/tests/fastapi/test_fastapi.py @@ -194,6 +194,7 @@ def return_error(): }, } + def test_heartbeat_sync(client): @checks.register def sync_ok(): @@ -226,6 +227,7 @@ def test_heartbeat_mixed_sync(client): @checks.register def sync_ok(): return [] + @checks.register async def async_ok(): return []