From 998025e5a601211180313dded0d7958e6d2ce12c Mon Sep 17 00:00:00 2001 From: Luigi Toscano Date: Wed, 27 Jun 2018 15:35:04 +0200 Subject: [PATCH] More Python 3 porting: filter and map, one import - port away from filter (list comprehension is the suggested way); - explicitly convert the result of map to a list (thus simulating the Python 2 behavior); - remove the last (newly introduced) relative import; - add a temporary py35 job to avoid clashes with the future official job from project-config. Python 3 unit tests should pass now. Story: 2002574 Task: 22141 Change-Id: I73786ed5ca238da1236e6847e25d4435aeebbd87 --- .zuul.yaml | 7 ++++++- config_tempest/services/base.py | 2 +- config_tempest/services/compute.py | 2 +- config_tempest/services/identity.py | 2 +- config_tempest/services/image.py | 4 ++-- config_tempest/services/network.py | 2 +- config_tempest/services/octavia.py | 2 +- config_tempest/services/volume.py | 2 +- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index cdb7cf83..1f4d599d 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,7 +1,7 @@ - project: check: jobs: - - openstack-tox-py35: + - python-tempestconf-tox-py35: voting: false - python-tempestconf-tox-cover - python-tempestconf-tempest-devstack-admin @@ -17,6 +17,11 @@ - python-tempestconf-tempest-packstack-demo - tripleo-ci-centos-7-containers-multinode +- job: + name: python-tempestconf-tox-py35 + parent: openstack-tox-py35 + description: Temporary local job which runs unit tests with py35 + - job: name: python-tempestconf-tox-cover parent: openstack-tox diff --git a/config_tempest/services/base.py b/config_tempest/services/base.py index f50efd9c..272f9c32 100644 --- a/config_tempest/services/base.py +++ b/config_tempest/services/base.py @@ -91,7 +91,7 @@ class VersionedService(Service): for version in body['versions']: if version['status'] != "DEPRECATED": versions.append(version) - return map(lambda x: x['id'], versions) + return list(map(lambda x: x['id'], versions)) def no_port_cut_url(self): # if there is no port defined, cut the url from version to the end diff --git a/config_tempest/services/compute.py b/config_tempest/services/compute.py index ced89009..23355d0d 100644 --- a/config_tempest/services/compute.py +++ b/config_tempest/services/compute.py @@ -25,7 +25,7 @@ class ComputeService(VersionedService): def set_extensions(self): body = self.do_get(self.service_url + '/extensions') body = json.loads(body) - self.extensions = map(lambda x: x['alias'], body['extensions']) + self.extensions = list(map(lambda x: x['alias'], body['extensions'])) def set_versions(self): url, top_level = self.no_port_cut_url() diff --git a/config_tempest/services/identity.py b/config_tempest/services/identity.py index ba5e39d8..f255279c 100644 --- a/config_tempest/services/identity.py +++ b/config_tempest/services/identity.py @@ -40,7 +40,7 @@ class IdentityService(VersionedService): body = self.do_get(self.service_url + '/extensions') body = json.loads(body) values = body['extensions']['values'] - self.extensions = map(lambda x: x['alias'], values) + self.extensions = list(map(lambda x: x['alias'], values)) return # Keystone api changed in v3, the concept of extensions changed. Right # now, all the existing extensions are part of keystone core api, so, diff --git a/config_tempest/services/image.py b/config_tempest/services/image.py index fe35e10a..498e903c 100644 --- a/config_tempest/services/image.py +++ b/config_tempest/services/image.py @@ -124,8 +124,8 @@ class ImageService(VersionedService): return self.client.show_image(image_id) except exceptions.NotFound: pass - found = filter(lambda x: x['name'] == image_name, - self.client.list_images()['images']) + found = [x for x in self.client.list_images()['images'] + if x['name'] == image_name] if found: return found[0] else: diff --git a/config_tempest/services/network.py b/config_tempest/services/network.py index 5f7ba4ea..26b25f1d 100644 --- a/config_tempest/services/network.py +++ b/config_tempest/services/network.py @@ -23,7 +23,7 @@ class NetworkService(VersionedService): def set_extensions(self): body = self.do_get(self.service_url + '/v2.0/extensions.json') body = json.loads(body) - self.extensions = map(lambda x: x['alias'], body['extensions']) + self.extensions = list(map(lambda x: x['alias'], body['extensions'])) def create_tempest_networks(self, has_neutron, conf, network_id): LOG.info("Setting up network") diff --git a/config_tempest/services/octavia.py b/config_tempest/services/octavia.py index 982a0bb5..dca0947a 100644 --- a/config_tempest/services/octavia.py +++ b/config_tempest/services/octavia.py @@ -13,7 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -from base import VersionedService +from config_tempest.services.base import VersionedService class LoadBalancerService(VersionedService): diff --git a/config_tempest/services/volume.py b/config_tempest/services/volume.py index 088b6f6b..86fe3e4e 100644 --- a/config_tempest/services/volume.py +++ b/config_tempest/services/volume.py @@ -25,7 +25,7 @@ class VolumeService(VersionedService): def set_extensions(self): body = self.do_get(self.service_url + '/extensions') body = json.loads(body) - self.extensions = map(lambda x: x['alias'], body['extensions']) + self.extensions = list(map(lambda x: x['alias'], body['extensions'])) def set_versions(self): url, top_level = self.no_port_cut_url()