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
This commit is contained in:
Luigi Toscano 2018-06-27 15:35:04 +02:00
parent ab4e518bab
commit 998025e5a6
8 changed files with 14 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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,

View File

@ -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:

View File

@ -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")

View File

@ -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):

View File

@ -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()