示例工程 38-observability-otel

38-observability-otel/02-dictconfig-full/test_dictconfig_full.py

python · 0.5 KB

"""test_dictconfig_full.py"""
 
from __future__ import annotations
 
from pathlib import Path
 
import pytest
from dictconfig_full import main, run
 
 
def test_console_and_file(tmp_path: Path) -> None:
    lines = run(tmp_path / "app.log")
    assert lines == ["INFO obs.dict hello", "WARNING obs.dict warn"]
 
 
def test_main_runs(capsys: pytest.CaptureFixture[str]) -> None:
    main()
    captured = capsys.readouterr()
    assert "INFO obs.dict hello" in captured.out
    assert "file_lines: ['INFO obs.dict hello', 'WARNING obs.dict warn']" in captured.out