File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import pytest
1010
1111from crawlee .events import LocalEventManager
12- from crawlee .events ._types import Event , EventSystemInfoData
12+ from crawlee .events ._types import Event
1313
1414
1515@pytest .fixture
@@ -19,13 +19,12 @@ async def async_listener(payload: Any) -> None:
1919
2020 al = AsyncMock ()
2121 update_wrapper (al , async_listener )
22- return al
22+ return AsyncMock ( target = async_listener )
2323
2424
2525async def test_emit_system_info_event (listener : AsyncMock ) -> None :
26- async with LocalEventManager (system_info_interval = timedelta (milliseconds = 50 )) as event_manager :
26+ system_info_interval = timedelta (milliseconds = 50 )
27+ test_tolerance_coefficient = 10
28+ async with LocalEventManager (system_info_interval = system_info_interval ) as event_manager :
2729 event_manager .on (event = Event .SYSTEM_INFO , listener = listener )
28- await asyncio .sleep (0.2 )
29-
30- assert listener .call_count >= 1
31- assert isinstance (listener .call_args [0 ][0 ], EventSystemInfoData )
30+ await asyncio .sleep (system_info_interval .total_seconds () * test_tolerance_coefficient )
You can’t perform that action at this time.
0 commit comments