Add support for Python 3.12 (#101651)

This commit is contained in:
Marc Mueller
2023-10-10 21:34:49 +02:00
committed by GitHub
parent 535e2b81ce
commit ba91aaa28d
28 changed files with 296 additions and 93 deletions

View File

@@ -3,6 +3,7 @@ from datetime import timedelta
from functools import lru_cache
import os
from pathlib import Path
import sys
from unittest.mock import patch
from lru import LRU # pylint: disable=no-name-in-module
@@ -63,6 +64,9 @@ async def test_basic_usage(hass: HomeAssistant, tmp_path: Path) -> None:
await hass.async_block_till_done()
@pytest.mark.skipif(
sys.version_info >= (3, 12), reason="not yet available on Python 3.12"
)
async def test_memory_usage(hass: HomeAssistant, tmp_path: Path) -> None:
"""Test we can setup and the service is registered."""
test_dir = tmp_path / "profiles"
@@ -94,6 +98,24 @@ async def test_memory_usage(hass: HomeAssistant, tmp_path: Path) -> None:
await hass.async_block_till_done()
@pytest.mark.skipif(sys.version_info < (3, 12), reason="still works on python 3.11")
async def test_memory_usage_py312(hass: HomeAssistant, tmp_path: Path) -> None:
"""Test raise an error on python3.11."""
entry = MockConfigEntry(domain=DOMAIN)
entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(entry.entry_id)
await hass.async_block_till_done()
assert hass.services.has_service(DOMAIN, SERVICE_MEMORY)
with pytest.raises(
HomeAssistantError,
match="Memory profiling is not supported on Python 3.12. Please use Python 3.11.",
):
await hass.services.async_call(
DOMAIN, SERVICE_MEMORY, {CONF_SECONDS: 0.000001}, blocking=True
)
async def test_object_growth_logging(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
) -> None: