47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
from yovision_brain import __version__
|
|
from yovision_brain.__main__ import main, runtime_info, smoke
|
|
|
|
|
|
def test_package_version() -> None:
|
|
assert __version__ == "0.1.0"
|
|
|
|
|
|
def test_module_help_runs_without_other_products() -> None:
|
|
result = subprocess.run(
|
|
[sys.executable, "-m", "yovision_brain", "--help"],
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
)
|
|
assert result.returncode == 0
|
|
assert "YoVision Brain runtime diagnostics" in result.stdout
|
|
|
|
|
|
def test_runtime_info_is_non_sensitive(capsys: pytest.CaptureFixture[str]) -> None:
|
|
assert main(["--runtime-info"]) == 0
|
|
payload = json.loads(capsys.readouterr().out)
|
|
assert set(payload) == {
|
|
"cuda_available",
|
|
"cuda_build",
|
|
"cuda_device_count",
|
|
"python",
|
|
"torch_installed",
|
|
"torch_version",
|
|
}
|
|
assert payload == runtime_info()
|
|
|
|
|
|
def test_cpu_tensor_smoke() -> None:
|
|
pytest.importorskip("torch")
|
|
result = smoke("cpu")
|
|
assert result["status"] == "ok"
|
|
assert result["device"] == "cpu"
|