22
33import asyncio
44import json
5+ import logging
56from collections .abc import Callable , Generator
67from unittest .mock import AsyncMock , Mock , patch
78
@@ -82,6 +83,15 @@ async def setup_message_handler(mqtt_session: Mock, mqtt_channel: MqttChannel) -
8283 return message_handler
8384
8485
86+ @pytest .fixture
87+ def warning_caplog (
88+ caplog : pytest .LogCaptureFixture ,
89+ ) -> Generator [pytest .LogCaptureFixture ]:
90+ """Fixture to capture warning messages."""
91+ caplog .set_level (logging .WARNING )
92+ yield caplog
93+
94+
8595async def home_home_data_no_devices () -> HomeData :
8696 """Mock home data API that returns no devices."""
8797 return HomeData (
@@ -163,7 +173,7 @@ async def test_concurrent_commands(
163173 mqtt_session : Mock ,
164174 mqtt_channel : MqttChannel ,
165175 mqtt_message_handler : Callable [[bytes ], None ],
166- caplog : pytest .LogCaptureFixture ,
176+ warning_caplog : pytest .LogCaptureFixture ,
167177) -> None :
168178 """Test handling multiple concurrent RPC commands."""
169179
@@ -187,7 +197,7 @@ async def test_concurrent_commands(
187197 assert result1 == TEST_RESPONSE
188198 assert result2 == TEST_RESPONSE2
189199
190- assert not caplog .records
200+ assert not warning_caplog .records
191201
192202
193203async def test_concurrent_commands_same_request_id (
0 commit comments