From a883adaa69d51224ec733653aee3bfe19bc53f20 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Sat, 1 Dec 2018 19:46:08 +0100 Subject: [PATCH] Py3: Replace map() with a list comprehension In Python 3, map() returns a map object, which is not JSON-serializable. Use a list comprehension to fix the issue. Change-Id: I1e50b5057bdca57fcca8a10882e878f63d102ac8 --- test/unit/common/middleware/s3api/test_service.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/unit/common/middleware/s3api/test_service.py b/test/unit/common/middleware/s3api/test_service.py index 431386d7cc..2f8286ba8b 100644 --- a/test/unit/common/middleware/s3api/test_service.py +++ b/test/unit/common/middleware/s3api/test_service.py @@ -31,9 +31,8 @@ def create_bucket_list_json(buckets): :param buckets: a list of tuples (or lists) consist of elements orderd as name, count, bytes """ - bucket_list = map( - lambda item: {'name': item[0], 'count': item[1], 'bytes': item[2]}, - list(buckets)) + bucket_list = [{'name': item[0], 'count': item[1], 'bytes': item[2]} + for item in buckets] return json.dumps(bucket_list)