fixup! Use a Runtime class to get information about container runtimes

This commit is contained in:
Alexis Métaireau 2025-03-25 12:34:37 +01:00
parent 3abbbad2e5
commit cc94c8ef5b

View file

@ -32,7 +32,13 @@ def test_get_runtime_name_linux(mocker: MockerFixture, tmp_path: Path) -> None:
def test_get_runtime_name_non_linux(mocker: MockerFixture, tmp_path: Path) -> None: def test_get_runtime_name_non_linux(mocker: MockerFixture, tmp_path: Path) -> None:
mocker.patch("platform.system", return_value="Windows") mocker.patch("platform.system", return_value="Windows")
mocker.patch("dangerzone.settings.get_config_dir", return_value=tmp_path) mocker.patch("dangerzone.settings.get_config_dir", return_value=tmp_path)
assert Runtime().name == "docker" mocker.patch(
"dangerzone.container_utils.shutil.which", return_value="/usr/bin/docker"
)
mocker.patch("dangerzone.container_utils.os.path.exists", return_value=True)
runtime = Runtime()
assert runtime.name == "docker"
assert runtime.path == Path("/usr/bin/docker")
mocker.patch("platform.system", return_value="Something else") mocker.patch("platform.system", return_value="Something else")
assert Runtime().name == "docker" assert Runtime().name == "docker"