File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 22
33import asyncio
44from datetime import timedelta
5- from functools import update_wrapper
65from typing import Any
76from unittest .mock import AsyncMock
87
@@ -17,15 +16,15 @@ def listener() -> AsyncMock:
1716 async def async_listener (payload : Any ) -> None :
1817 pass
1918
20- al = AsyncMock ()
21- update_wrapper (al , async_listener )
22- return al
19+ return AsyncMock (target = async_listener )
2320
2421
2522async def test_emit_system_info_event (listener : AsyncMock ) -> None :
26- async with LocalEventManager (system_info_interval = timedelta (milliseconds = 50 )) as event_manager :
23+ system_info_interval = timedelta (milliseconds = 50 )
24+ test_tolerance_coefficient = 10
25+ async with LocalEventManager (system_info_interval = system_info_interval ) as event_manager :
2726 event_manager .on (event = Event .SYSTEM_INFO , listener = listener )
28- await asyncio .sleep (0.2 )
27+ await asyncio .sleep (system_info_interval . total_seconds () * test_tolerance_coefficient )
2928
3029 assert listener .call_count >= 1
3130 assert isinstance (listener .call_args [0 ][0 ], EventSystemInfoData )
You can’t perform that action at this time.
0 commit comments