diff --git a/python/ray/tests/test_actor_failures.py b/python/ray/tests/test_actor_failures.py index aa1f93ad66040..c96ac610bb2c0 100644 --- a/python/ray/tests/test_actor_failures.py +++ b/python/ray/tests/test_actor_failures.py @@ -994,8 +994,14 @@ async def exit(self): a = AsyncActor.remote() ray.get(a.__ray_ready__.remote()) - with pytest.raises(ray.exceptions.RayActorError): + with pytest.raises(ray.exceptions.RayActorError) as exc_info: ray.get(a.exit.remote()) + assert ( + # Exited when task execution returns + "exit_actor()" in str(exc_info.value) + # Exited during periodical check in worker + or "User requested to exit the actor" in str(exc_info.value) + ) def verify(): return temp_file_atexit.exists() @@ -1024,14 +1030,8 @@ async def create(self): a = AsyncActor.remote() ray.get(a.__ray_ready__.remote()) - with pytest.raises(ray.exceptions.RayActorError) as exc_info: + with pytest.raises(ray.exceptions.RayActorError): ray.get(a.exit.remote()) - assert ( - # Exited when task execution returns - "exit_actor()" in str(exc_info.value) - # Exited during periodical check in worker - or "User requested to exit the actor" in str(exc_info.value) - ) with pytest.raises(ray.exceptions.RayActorError): ray.get(a.create.remote())