From b7dc3f234bfa8800546c91f6bf5cf05a823f3221 Mon Sep 17 00:00:00 2001 From: wangqi Date: Thu, 19 Apr 2018 08:26:08 +0000 Subject: [PATCH] Modify the empty list ensure method Change-Id: I32c21637c39b20a20c9a42042408ab76c8c96d7a --- glance/api/v2/images.py | 4 ++-- glance/tests/unit/test_auth.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/glance/api/v2/images.py b/glance/api/v2/images.py index 59eb317cee..3909d51399 100644 --- a/glance/api/v2/images.py +++ b/glance/api/v2/images.py @@ -228,10 +228,10 @@ class ImagesController(object): path = change['path'] path_root = path[0] value = change['value'] - if path_root == 'locations' and value == []: + if path_root == 'locations' and not value: msg = _("Cannot set locations to empty list.") raise webob.exc.HTTPForbidden(msg) - elif path_root == 'locations' and value != []: + elif path_root == 'locations' and value: self._do_replace_locations(image, value) elif path_root == 'owner' and req.context.is_admin == False: msg = _("Owner can't be updated by non admin.") diff --git a/glance/tests/unit/test_auth.py b/glance/tests/unit/test_auth.py index 56a62d4717..4807f14de7 100644 --- a/glance/tests/unit/test_auth.py +++ b/glance/tests/unit/test_auth.py @@ -72,7 +72,7 @@ class V2Token(object): service = catalog[-1] endpoint_list = [] - if region_list == []: + if not region_list: endpoint_list.append(self.base_endpoint) else: for region in region_list: