Use subprocess.check_output in tests (#5465)

This commit is contained in:
Edward Oakes
2019-08-17 22:25:17 -07:00
committed by Robert Nishihara
parent c7ae4e5e1f
commit 0440c00019
4 changed files with 39 additions and 47 deletions
+12 -11
View File
@@ -10,18 +10,19 @@ import time
import ray
from ray.tests.utils import run_and_get_output
def _test_cleanup_on_driver_exit(num_redis_shards):
stdout = run_and_get_output([
"ray",
"start",
"--head",
"--num-redis-shards",
str(num_redis_shards),
])
lines = [m.strip() for m in stdout.split("\n")]
output = ray.utils.decode(
subprocess.check_output(
[
"ray",
"start",
"--head",
"--num-redis-shards",
str(num_redis_shards),
],
stderr=subprocess.STDOUT))
lines = [m.strip() for m in output.split("\n")]
init_cmd = [m for m in lines if m.startswith("ray.init")]
assert 1 == len(init_cmd)
redis_address = init_cmd[0].split("redis_address=\"")[-1][:-2]
@@ -90,7 +91,7 @@ def _test_cleanup_on_driver_exit(num_redis_shards):
assert (0, 1) == StateSummary()
ray.shutdown()
subprocess.Popen(["ray", "stop"]).wait()
subprocess.check_output(["ray", "stop"])
@pytest.mark.skipif(