2
2
3
3
import asyncio
4
4
import json
5
+ import logging
5
6
from collections .abc import Callable , Generator
6
7
from unittest .mock import AsyncMock , Mock , patch
7
8
@@ -82,6 +83,15 @@ async def setup_message_handler(mqtt_session: Mock, mqtt_channel: MqttChannel) -
82
83
return message_handler
83
84
84
85
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
+
85
95
async def home_home_data_no_devices () -> HomeData :
86
96
"""Mock home data API that returns no devices."""
87
97
return HomeData (
@@ -163,7 +173,7 @@ async def test_concurrent_commands(
163
173
mqtt_session : Mock ,
164
174
mqtt_channel : MqttChannel ,
165
175
mqtt_message_handler : Callable [[bytes ], None ],
166
- caplog : pytest .LogCaptureFixture ,
176
+ warning_caplog : pytest .LogCaptureFixture ,
167
177
) -> None :
168
178
"""Test handling multiple concurrent RPC commands."""
169
179
@@ -187,7 +197,7 @@ async def test_concurrent_commands(
187
197
assert result1 == TEST_RESPONSE
188
198
assert result2 == TEST_RESPONSE2
189
199
190
- assert not caplog .records
200
+ assert not warning_caplog .records
191
201
192
202
193
203
async def test_concurrent_commands_same_request_id (
0 commit comments