Skip to content

Commit 6c29375

Browse files
thaJeztahulyssessouza
authored andcommitted
Fix ImageCollectionTest.test_pull_multiple flakiness
The ImageCollectionTest.test_pull_multiple test performs a `docker pull` without a `:tag` specified) to pull all tags of the given repository (image). After pulling the image, the image(s) pulled are checked to verify if the list of images contains the `:latest` tag. However, the test assumes that all tags of the image are tags for the same version of the image (same digest), and thus a *single* image is returned, which is not always the case. Currently, the `hello-world:latest` and `hello-world:linux` tags point to a different digest, therefore the `client.images.pull()` returns multiple images: one image for digest, making the test fail: =================================== FAILURES =================================== ____________________ ImageCollectionTest.test_pull_multiple ____________________ tests/integration/models_images_test.py:90: in test_pull_multiple assert len(images) == 1 E AssertionError: assert 2 == 1 E + where 2 = len([<Image: 'hello-world:linux'>, <Image: 'hello-world:latest'>]) This patch updates the test to not assume a single image is returned, and instead loop through the list of images and check if any of the images contains the `:latest` tag. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9b0d07f commit 6c29375

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/integration/models_images_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ def test_pull_with_sha(self):
8787
def test_pull_multiple(self):
8888
client = docker.from_env(version=TEST_API_VERSION)
8989
images = client.images.pull('hello-world')
90-
assert len(images) == 1
91-
assert 'hello-world:latest' in images[0].attrs['RepoTags']
90+
assert len(images) >= 1
91+
assert any([
92+
'hello-world:latest' in img.attrs['RepoTags'] for img in images
93+
])
9294

9395
def test_load_error(self):
9496
client = docker.from_env(version=TEST_API_VERSION)

0 commit comments

Comments
 (0)