Skip to content

Commit 61a5349

Browse files
authored
Try to make integration tests for actor events less flaky (#55)
Let's try just waiting longer for the `SYSTEM_INFO` event to happen, I think it will be enough. If not, we can work on it more.
1 parent 09dd8ac commit 61a5349

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/integration/test_actor_events.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@ class TestActorEvents:
1111
async def test_interval_events(self, make_actor: ActorFactory) -> None:
1212
async def main() -> None:
1313
import os
14+
from typing import Any, Callable
1415

1516
from apify.consts import ActorEventType, ApifyEnvVars
1617

1718
os.environ[ApifyEnvVars.PERSIST_STATE_INTERVAL_MILLIS] = '900'
1819

19-
def on_event(event_type): # type: ignore
20-
async def log_event(data): # type: ignore
20+
def on_event(event_type: ActorEventType) -> Callable:
21+
async def log_event(data: Any) -> None:
2122
await Actor.push_data({'event_type': event_type, 'data': data})
2223
return log_event
2324

2425
async with Actor:
25-
Actor.on(ActorEventType.SYSTEM_INFO, on_event(ActorEventType.SYSTEM_INFO)) # type: ignore
26-
Actor.on(ActorEventType.PERSIST_STATE, on_event(ActorEventType.PERSIST_STATE)) # type: ignore
27-
await asyncio.sleep(3)
26+
Actor.on(ActorEventType.SYSTEM_INFO, on_event(ActorEventType.SYSTEM_INFO))
27+
Actor.on(ActorEventType.PERSIST_STATE, on_event(ActorEventType.PERSIST_STATE))
28+
await asyncio.sleep(10)
2829

2930
actor = await make_actor('actor-interval-events', main_func=main)
3031

0 commit comments

Comments
 (0)