From be86aec05d7f21b929a45ddcab73269791c90153 Mon Sep 17 00:00:00 2001 From: zhufl <zhu.fanglei@zte.com.cn> Date: Tue, 25 Feb 2020 16:56:51 +0800 Subject: [PATCH] Change bytes to str in servers_client for python3 In python3, the response body of clients will be of type bytes, but jsonschema.validate expects parameter of type str, so we need change bytes to str when needed, otherwise we will get errors like "HTTP response body is invalid (b'' is not of type 'object', 'string'" Change-Id: If4cad1b0f706aeb5f83931cb6928806a2c5cee8e Closes-Bug: #1864625 --- tempest/lib/services/compute/servers_client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tempest/lib/services/compute/servers_client.py b/tempest/lib/services/compute/servers_client.py index a6871371cb..b49a250308 100644 --- a/tempest/lib/services/compute/servers_client.py +++ b/tempest/lib/services/compute/servers_client.py @@ -209,6 +209,9 @@ class ServersClient(base_compute_client.BaseComputeClient): post_body) if body: body = json.loads(body) + else: + if isinstance(body, bytes): + body = body.decode('utf-8') self.validate_response(schema, resp, body) return rest_client.ResponseBody(resp, body)