From a7f84b536f7948a483bc8347df1c2dc0c2b83425 Mon Sep 17 00:00:00 2001 From: Joey Jiang <452084368@qq.com> Date: Fri, 21 Jun 2019 17:08:25 +0800 Subject: [PATCH] Fix no cpus test (#5009) --- python/ray/tests/conftest.py | 8 ++++++++ python/ray/tests/test_actor.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/python/ray/tests/conftest.py b/python/ray/tests/conftest.py index 2e670fb0a..f7c93fd50 100644 --- a/python/ray/tests/conftest.py +++ b/python/ray/tests/conftest.py @@ -56,6 +56,14 @@ def _ray_start(**kwargs): ray.shutdown() +# The following fixture will start ray with 0 cpu. +@pytest.fixture +def ray_start_no_cpu(request): + param = getattr(request, "param", {}) + with _ray_start(num_cpus=0, **param) as res: + yield res + + # The following fixture will start ray with 1 cpu. @pytest.fixture def ray_start_regular(request): diff --git a/python/ray/tests/test_actor.py b/python/ray/tests/test_actor.py index dd726e00f..932f7b090 100644 --- a/python/ray/tests/test_actor.py +++ b/python/ray/tests/test_actor.py @@ -842,7 +842,7 @@ def test_remote_functions_not_scheduled_on_actors(ray_start_regular): assert actor_id not in resulting_ids -def test_actors_on_nodes_with_no_cpus(ray_start_regular): +def test_actors_on_nodes_with_no_cpus(ray_start_no_cpu): @ray.remote class Foo(object): def method(self):