Skip to content

Commit

Permalink
Ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamalama committed Apr 25, 2024
1 parent 47c008a commit 237fb02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/core/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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"
Expand All @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions tests/fastapi/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def return_error():
},
}


def test_heartbeat_sync(client):
@checks.register
def sync_ok():
Expand Down Expand Up @@ -226,6 +227,7 @@ def test_heartbeat_mixed_sync(client):
@checks.register
def sync_ok():
return []

@checks.register
async def async_ok():
return []
Expand Down

0 comments on commit 237fb02

Please sign in to comment.