From 360a84e62ab80cd3e9ba165e2053ff1b9318e248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Nesveda?= Date: Thu, 9 Feb 2023 09:48:36 +0100 Subject: [PATCH] Try to make integration tests for actor events less flaky --- tests/integration/test_actor_events.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/integration/test_actor_events.py b/tests/integration/test_actor_events.py index 6172740d..55b07af3 100644 --- a/tests/integration/test_actor_events.py +++ b/tests/integration/test_actor_events.py @@ -11,20 +11,21 @@ class TestActorEvents: async def test_interval_events(self, make_actor: ActorFactory) -> None: async def main() -> None: import os + from typing import Any, Callable from apify.consts import ActorEventType, ApifyEnvVars os.environ[ApifyEnvVars.PERSIST_STATE_INTERVAL_MILLIS] = '900' - def on_event(event_type): # type: ignore - async def log_event(data): # type: ignore + def on_event(event_type: ActorEventType) -> Callable: + async def log_event(data: Any) -> None: await Actor.push_data({'event_type': event_type, 'data': data}) return log_event async with Actor: - Actor.on(ActorEventType.SYSTEM_INFO, on_event(ActorEventType.SYSTEM_INFO)) # type: ignore - Actor.on(ActorEventType.PERSIST_STATE, on_event(ActorEventType.PERSIST_STATE)) # type: ignore - await asyncio.sleep(3) + Actor.on(ActorEventType.SYSTEM_INFO, on_event(ActorEventType.SYSTEM_INFO)) + Actor.on(ActorEventType.PERSIST_STATE, on_event(ActorEventType.PERSIST_STATE)) + await asyncio.sleep(10) actor = await make_actor('actor-interval-events', main_func=main)