Fix TypeError when there exists image with size None

When there exists image with size None(e.g.,images whose status is
queued), test_list_images_param_sort will raise TypeError:
TypeError: '<' not supported between instances of 'int' and 'NoneType',
So we should ignore images with size None.

Change-Id: Ie084c65303238eaeff0a753915356d72aa039434
Closes-Bug: #1905515
This commit is contained in:
zhufl 2020-11-25 15:36:13 +08:00
parent 805f2a070b
commit 940a9e2159
1 changed files with 2 additions and 1 deletions

View File

@ -402,7 +402,8 @@ class ListUserImagesTest(base.BaseV2ImageTest):
# Validate that the list was fetched sorted accordingly
msg = 'No images were found that met the filter criteria.'
self.assertNotEmpty(images_list, msg)
sorted_list = [image['size'] for image in images_list]
sorted_list = [image['size'] for image in images_list
if image['size'] is not None]
msg = 'The list of images was not sorted correctly.'
self.assertEqual(sorted(sorted_list, reverse=desc), sorted_list, msg)