reranker / tests /test_logging.py
Hemprasad Badgujar
Add JD parsing, central config, checkpoints & LLM
700e896
Raw History Blame Contribute Delete
934 Bytes
"""Structured logging — step() works, and silence mode (RERANKER_LOG=0) doesn't crash."""
from __future__ import annotations
import pytest
from common import logging as logging_module
from common.logging import step
def test_step_yields_metrics_and_runs() -> None:
with step("test.stage", rows_in=3) as metrics:
metrics["rows_out"] = 3
assert metrics["rows_out"] == 3
def test_silence_mode_does_not_crash(monkeypatch: pytest.MonkeyPatch) -> None:
# RERANKER_LOG=0 must filter cleanly — structlog rejects non-standard levels (CRITICAL+1 → KeyError).
monkeypatch.setenv("RERANKER_LOG", "0")
try:
logging_module._configure_logging(force=True)
with step("test.silence") as metrics:
metrics["ok"] = True
finally:
monkeypatch.delenv("RERANKER_LOG", raising=False)
logging_module._configure_logging(force=True) # restore normal config for other tests