@@ -110,32 +110,30 @@ def test_save_iterator_bytes_and_load_from_iterator_list_of_images(
110110 pytest .param (
111111 "podman" ,
112112 marks = pytest .mark .xfail (
113- reason = "podman lists images with registry in image name "
113+ reason = "podman includes all repo tags matching images ref "
114114 ),
115115 ),
116116 ],
117117 indirect = True ,
118118)
119- def test_filter_when_listing (ctr_client : DockerClient ):
119+ def test_list_filters (ctr_client : DockerClient ):
120120 ctr_client .pull (["hello-world" , "busybox" ])
121- images_listed = ctr_client .image .list (filters = dict ( reference = " hello-world" ))
121+ images_listed = ctr_client .image .list (filters = [( " reference" , " hello-world" )] )
122122 tags = {tag .split ("/" )[- 1 ] for image in images_listed for tag in image .repo_tags }
123123 assert tags == {"hello-world:latest" }
124124
125125
126- def test_filter_when_listing_old_signature (docker_client : DockerClient ):
126+ def test_list_filters_old_signature (docker_client : DockerClient ):
127127 """Check backward compatibility of the DockerClient.image.list() API."""
128128 docker_client .pull (["hello-world" , "busybox" ])
129- with pytest .warns (DeprecationWarning ) as warnings_emmitted :
130- images_listed = docker_client .image .list ({"reference" : "hello-world" })
131-
132- warning_message = str (warnings_emmitted .list [0 ].message )
133- assert "docker.image.list({'reference': 'hello-world'}" in warning_message
134- assert "docker.image.list(filters={'reference': 'hello-world'}" in warning_message
135- tags = set ()
136- for image in images_listed :
137- for tag in image .repo_tags :
138- tags .add (tag )
129+ expected_warning = (
130+ r"Passing filters as a mapping is deprecated, replace with an iterable "
131+ r"of tuples instead, as so:\n"
132+ r"filters=\[\(.*\)\]"
133+ )
134+ with pytest .warns (DeprecationWarning , match = expected_warning ):
135+ images_listed = docker_client .image .list (filters = {"reference" : "hello-world" })
136+ tags = {tag .split ("/" )[- 1 ] for image in images_listed for tag in image .repo_tags }
139137 assert tags == {"hello-world:latest" }
140138
141139
@@ -146,13 +144,13 @@ def test_filter_when_listing_old_signature(docker_client: DockerClient):
146144 pytest .param (
147145 "podman" ,
148146 marks = pytest .mark .xfail (
149- reason = "podman lists images with registry in image name "
147+ reason = "podman includes all repo tags matching images ref "
150148 ),
151149 ),
152150 ],
153151 indirect = True ,
154152)
155- def test_use_first_argument_to_filter (ctr_client : DockerClient ):
153+ def test_list_filter_by_name (ctr_client : DockerClient ):
156154 ctr_client .pull (["hello-world" , "busybox" ])
157155 images_listed = ctr_client .image .list ("hello-world" )
158156 tags = {tag .split ("/" )[- 1 ] for image in images_listed for tag in image .repo_tags }
0 commit comments