示例工程 01-orientation

01-orientation/01-hello-runtime/test_hello_runtime.py

python · 0.7 KB

"""test_hello_runtime.py"""
 
from __future__ import annotations
 
import pytest
from hello_runtime import runtime_info
 
 
def test_runtime_fields() -> None:
    info = runtime_info()
    assert info["implementation"] == "CPython"
    assert str(info["version"]).startswith("3.")
    assert isinstance(info["executable"], str)
    assert info["executable"]
    assert info["path0"] is not None
    assert str(info["cache_tag"]).startswith("cpython-3")
 
 
def test_output_format(capsys: pytest.CaptureFixture[str]) -> None:
    from hello_runtime import main
 
    main()
    out = capsys.readouterr().out
    assert "implementation: CPython" in out
    assert "path0:" in out