diff --git a/tests/unit/actor/test_actor_lifecycle.py b/tests/unit/actor/test_actor_lifecycle.py index 4b33b3df..2ece897b 100644 --- a/tests/unit/actor/test_actor_lifecycle.py +++ b/tests/unit/actor/test_actor_lifecycle.py @@ -220,7 +220,6 @@ async def test_actor_handles_migrating_event_correctly(monkeypatch: pytest.Monke """Test that Actor handles MIGRATING events correctly by emitting PERSIST_STATE.""" # This should test whether when you get a MIGRATING event, # the Actor automatically emits the PERSIST_STATE event with data `{'isMigrating': True}` - monkeypatch.setenv(ApifyEnvVars.PERSIST_STATE_INTERVAL_MILLIS, '500') monkeypatch.setenv(ApifyEnvVars.IS_AT_HOME, '1') monkeypatch.setenv(ActorEnvVars.RUN_ID, 'asdf') @@ -285,9 +284,8 @@ async def handler(websocket: websockets.asyncio.server.ServerConnection) -> None await asyncio.sleep(1) - assert len(persist_state_events_data) >= 3 - - print(persist_state_events_data) + # It is enough to check the persist state event we send manually and the crawler final one. + assert len(persist_state_events_data) >= 2 # Expect last event to be is_migrating=False (persistence event on exiting EventManager) assert persist_state_events_data.pop() == EventPersistStateData(is_migrating=False)