diff --git a/.github/workflows/run_code_checks.yaml b/.github/workflows/run_code_checks.yaml index 6bf008115e..b51da18ab9 100644 --- a/.github/workflows/run_code_checks.yaml +++ b/.github/workflows/run_code_checks.yaml @@ -36,6 +36,7 @@ jobs: httpbin_url: ${{ secrets.APIFY_HTTPBIN_TOKEN && format('https://httpbin.apify.actor?token={0}', secrets.APIFY_HTTPBIN_TOKEN) || 'https://httpbin.org'}} with: python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' + os: '["ubuntu-latest", "windows-latest", "macos-latest"]' docs_check: name: Docs check diff --git a/tests/unit/events/test_local_event_manager.py b/tests/unit/events/test_local_event_manager.py index 481c7da16b..bc50c84c92 100644 --- a/tests/unit/events/test_local_event_manager.py +++ b/tests/unit/events/test_local_event_manager.py @@ -2,30 +2,24 @@ import asyncio from datetime import timedelta -from functools import update_wrapper from typing import Any from unittest.mock import AsyncMock -import pytest - from crawlee.events import LocalEventManager from crawlee.events._types import Event, EventSystemInfoData -@pytest.fixture -def listener() -> AsyncMock: - async def async_listener(payload: Any) -> None: - pass - - al = AsyncMock() - update_wrapper(al, async_listener) - return al +async def test_emit_system_info_event() -> None: + mocked_listener = AsyncMock() + async def async_listener(payload: Any) -> None: + mocked_listener(payload) -async def test_emit_system_info_event(listener: AsyncMock) -> None: - async with LocalEventManager(system_info_interval=timedelta(milliseconds=50)) as event_manager: - event_manager.on(event=Event.SYSTEM_INFO, listener=listener) - await asyncio.sleep(0.2) + system_info_interval = timedelta(milliseconds=50) + test_tolerance_coefficient = 10 + async with LocalEventManager(system_info_interval=system_info_interval) as event_manager: + event_manager.on(event=Event.SYSTEM_INFO, listener=async_listener) + await asyncio.sleep(system_info_interval.total_seconds() * test_tolerance_coefficient) - assert listener.call_count >= 1 - assert isinstance(listener.call_args[0][0], EventSystemInfoData) + assert mocked_listener.call_count >= 1 + assert isinstance(mocked_listener.call_args[0][0], EventSystemInfoData)