mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Ensure random temp dir is used during MQTT CI tests (#137221)
This commit is contained in:
parent
a5eda3faf1
commit
30af9057d1
@ -38,7 +38,7 @@ def temp_dir_prefix() -> str:
|
||||
return "test"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@pytest.fixture(autouse=True)
|
||||
def mock_temp_dir(temp_dir_prefix: str) -> Generator[str]:
|
||||
"""Mock the certificate temp directory."""
|
||||
with patch(
|
||||
|
@ -4,7 +4,6 @@ import asyncio
|
||||
from collections.abc import Callable
|
||||
from datetime import timedelta
|
||||
from pathlib import Path
|
||||
from random import getrandbits
|
||||
import shutil
|
||||
import tempfile
|
||||
from unittest.mock import MagicMock, patch
|
||||
@ -199,7 +198,6 @@ async def test_reading_non_exitisting_certificate_file() -> None:
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("temp_dir_prefix", "unknown")
|
||||
async def test_return_default_get_file_path(
|
||||
hass: HomeAssistant, mock_temp_dir: str
|
||||
) -> None:
|
||||
@ -211,12 +209,8 @@ async def test_return_default_get_file_path(
|
||||
and mqtt.util.get_file_path("some_option", "mydefault") == "mydefault"
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.mqtt.util.TEMP_DIR_NAME",
|
||||
f"home-assistant-mqtt-other-{getrandbits(10):03x}",
|
||||
) as temp_dir_name:
|
||||
tempdir = Path(tempfile.gettempdir()) / temp_dir_name
|
||||
assert await hass.async_add_executor_job(_get_file_path, tempdir)
|
||||
temp_dir = Path(tempfile.gettempdir()) / mock_temp_dir
|
||||
assert await hass.async_add_executor_job(_get_file_path, temp_dir)
|
||||
|
||||
|
||||
async def test_waiting_for_client_not_loaded(
|
||||
|
Loading…
x
Reference in New Issue
Block a user