Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added kepler/.coverage
Binary file not shown.
2 changes: 2 additions & 0 deletions kepler/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
19 changes: 19 additions & 0 deletions kepler/tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Binary file added kosmos/.coverage
Binary file not shown.
23 changes: 23 additions & 0 deletions kosmos/tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Loading