1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add packaging as default requirement (#97712)

This commit is contained in:
Marc Mueller
2023-08-04 12:29:18 +02:00
committed by GitHub
parent 6adb06956b
commit 447479d0a0
5 changed files with 20 additions and 10 deletions

View File

@@ -1,8 +1,10 @@
"""Test the runner."""
import asyncio
from collections.abc import Iterator
import threading
from unittest.mock import patch
import packaging.tags
import py
import pytest
@@ -147,19 +149,22 @@ async def test_unhandled_exception_traceback(
def test__enable_posix_spawn() -> None:
"""Test that we can enable posix_spawn on Alpine."""
"""Test that we can enable posix_spawn on musllinux."""
def _mock_alpine_exists(path):
return path == "/etc/alpine-release"
def _mock_sys_tags_any() -> Iterator[packaging.tags.Tag]:
yield from packaging.tags.parse_tag("py3-none-any")
with patch.object(runner.subprocess, "_USE_POSIX_SPAWN", False), patch.object(
runner.os.path, "exists", _mock_alpine_exists
def _mock_sys_tags_musl() -> Iterator[packaging.tags.Tag]:
yield from packaging.tags.parse_tag("cp311-cp311-musllinux_1_1_x86_64")
with patch.object(runner.subprocess, "_USE_POSIX_SPAWN", False), patch(
"homeassistant.runner.packaging.tags.sys_tags", side_effect=_mock_sys_tags_musl
):
runner._enable_posix_spawn()
assert runner.subprocess._USE_POSIX_SPAWN is True
with patch.object(runner.subprocess, "_USE_POSIX_SPAWN", False), patch.object(
runner.os.path, "exists", return_value=False
with patch.object(runner.subprocess, "_USE_POSIX_SPAWN", False), patch(
"homeassistant.runner.packaging.tags.sys_tags", side_effect=_mock_sys_tags_any
):
runner._enable_posix_spawn()
assert runner.subprocess._USE_POSIX_SPAWN is False