diff --git a/kepler/.coverage b/kepler/.coverage new file mode 100644 index 0000000..9b9d1a8 Binary files /dev/null and b/kepler/.coverage differ diff --git a/kepler/pyproject.toml b/kepler/pyproject.toml index 3b3da6f..30fc3cd 100644 --- a/kepler/pyproject.toml +++ b/kepler/pyproject.toml @@ -58,6 +58,8 @@ show_missing = true [tool.pytest.ini_options] minversion = "6.0" log_cli_level = "INFO" +# Retain INFO logs in the "Captured log call" section when run interactively. +log_level = "INFO" # Linting tools configuration [tool.ruff] diff --git a/kepler/tests/integration/test_charm.py b/kepler/tests/integration/test_charm.py index f3852e5..62d61fa 100644 --- a/kepler/tests/integration/test_charm.py +++ b/kepler/tests/integration/test_charm.py @@ -39,3 +39,22 @@ def test_deploy(charm: pathlib.Path, juju: jubilant.Juju): } juju.deploy(charm, app=APP_NAME, resources=resources) juju.wait(jubilant.all_active) + + +def test_jubilant_info_logs_captured( + charm: pathlib.Path, juju: jubilant.Juju, caplog: pytest.LogCaptureFixture +): + """Jubilant's INFO logs must be retained in pytest's captured-log section.""" + juju.wait(jubilant.all_active) + # Force Jubilant's logger to emit at INFO (the level the doc claim concerns) so the + # assertion is deterministic regardless of how Jubilant configures its own logger. + jubilant_logger = logging.getLogger("jubilant") + jubilant_logger.setLevel(logging.INFO) + jubilant_logger.info("integration test info probe") + captured_info = [ + record + for record in caplog.records + if (record.name == "jubilant" or record.name.startswith("jubilant.")) + and record.levelno >= logging.INFO + ] + assert captured_info, "expected Jubilant INFO logs to be retained in caplog" diff --git a/kosmos/.coverage b/kosmos/.coverage new file mode 100644 index 0000000..72b63e9 Binary files /dev/null and b/kosmos/.coverage differ diff --git a/kosmos/tests/integration/test_charm.py b/kosmos/tests/integration/test_charm.py index f3852e5..5d815a7 100644 --- a/kosmos/tests/integration/test_charm.py +++ b/kosmos/tests/integration/test_charm.py @@ -39,3 +39,26 @@ def test_deploy(charm: pathlib.Path, juju: jubilant.Juju): } juju.deploy(charm, app=APP_NAME, resources=resources) juju.wait(jubilant.all_active) + + +@pytest.mark.xfail( + strict=True, + reason="without log_level=INFO, Jubilant INFO logs are not captured", +) +def test_jubilant_info_logs_captured( + charm: pathlib.Path, juju: jubilant.Juju, caplog: pytest.LogCaptureFixture +): + """Jubilant's INFO logs must be retained in pytest's captured-log section.""" + juju.wait(jubilant.all_active) + # Force Jubilant's logger to emit at INFO (the level the doc claim concerns) so the + # assertion is deterministic regardless of how Jubilant configures its own logger. + jubilant_logger = logging.getLogger("jubilant") + jubilant_logger.setLevel(logging.INFO) + jubilant_logger.info("integration test info probe") + captured_info = [ + record + for record in caplog.records + if (record.name == "jubilant" or record.name.startswith("jubilant.")) + and record.levelno >= logging.INFO + ] + assert captured_info, "expected Jubilant INFO logs to be retained in caplog"