From c8260a5966a913dbcdb8c94ea0b5559f9e677436 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 26 Mar 2024 15:52:38 +0100 Subject: [PATCH] Remove test cases for task eager_start <3.12 (#114243) --- tests/test_core.py | 22 ---------------------- tests/util/test_async.py | 27 --------------------------- 2 files changed, 49 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index 1aaf417f9eb473..11fda50a180a90 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -9,7 +9,6 @@ import gc import logging import os -import sys from tempfile import TemporaryDirectory import threading import time @@ -334,9 +333,6 @@ async def job(): assert len(hass.add_job.mock_calls) == 0 -@pytest.mark.skipif( - sys.version_info < (3, 12), reason="eager_start is only supported for Python 3.12" -) async def test_async_create_task_eager_start_schedule_coroutine() -> None: """Test that we schedule coroutines and add jobs to the job pool.""" hass = MagicMock(loop=MagicMock(wraps=asyncio.get_running_loop())) @@ -350,24 +346,6 @@ async def job(): assert len(hass.add_job.mock_calls) == 0 -@pytest.mark.skipif( - sys.version_info >= (3, 12), reason="eager_start is not supported on < 3.12" -) -async def test_async_create_task_eager_start_fallback_schedule_coroutine() -> None: - """Test that we schedule coroutines and add jobs to the job pool.""" - hass = MagicMock(loop=MagicMock(wraps=asyncio.get_running_loop())) - - async def job(): - pass - - ha.HomeAssistant.async_create_task(hass, job(), eager_start=True) - assert len(hass.loop.call_soon.mock_calls) == 1 - # Should fallback to loop.create_task since 3.11 does - # not support eager_start - assert len(hass.loop.create_task.mock_calls) == 0 - assert len(hass.add_job.mock_calls) == 0 - - async def test_async_create_task_schedule_coroutine_with_name() -> None: """Test that we schedule coroutines and add jobs to the job pool with a name.""" hass = MagicMock(loop=MagicMock(wraps=asyncio.get_running_loop())) diff --git a/tests/util/test_async.py b/tests/util/test_async.py index 1029d67070389a..50eecec72f6de3 100644 --- a/tests/util/test_async.py +++ b/tests/util/test_async.py @@ -1,7 +1,6 @@ """Tests for async util methods from Python source.""" import asyncio -import sys import time from unittest.mock import MagicMock, Mock, patch @@ -271,7 +270,6 @@ async def test_callback_is_always_scheduled(hass: HomeAssistant) -> None: mock_call_soon_threadsafe.assert_called_once() -@pytest.mark.skipif(sys.version_info < (3, 12), reason="Test requires Python 3.12+") async def test_create_eager_task_312(hass: HomeAssistant) -> None: """Test create_eager_task schedules a task eagerly in the event loop. @@ -294,28 +292,3 @@ async def _eager_task(): assert events == ["eager", "normal"] await task1 await task2 - - -@pytest.mark.skipif(sys.version_info >= (3, 12), reason="Test requires < Python 3.12") -async def test_create_eager_task_pre_312(hass: HomeAssistant) -> None: - """Test create_eager_task schedules a task in the event loop. - - For older python versions, the task is scheduled normally. - """ - events = [] - - async def _normal_task(): - events.append("normal") - - async def _eager_task(): - events.append("eager") - - task1 = hasync.create_eager_task(_eager_task()) - task2 = asyncio.create_task(_normal_task()) - - assert events == [] - - await asyncio.sleep(0) - assert events == ["eager", "normal"] - await task1 - await task2