11import re
22import subprocess
3+ import sys
34from pathlib import Path
45from typing import Dict , List
56from unittest .mock import patch
@@ -121,11 +122,13 @@ class TestDockerPull:
121122 def test_docker_pull_image_success (self ):
122123 with patch ("subprocess.run" ) as call :
123124 docker_pull_image ("ggshield-non-existant" , DOCKER_TIMEOUT )
124- call .assert_called_once_with (
125- ["docker" , "pull" , "ggshield-non-existant" ],
126- check = True ,
127- timeout = DOCKER_TIMEOUT ,
128- )
125+ call .assert_called_once ()
126+ args , kwargs = call .call_args
127+ assert args == (["docker" , "pull" , "ggshield-non-existant" ],)
128+ assert kwargs ["check" ] is True
129+ assert kwargs ["timeout" ] == DOCKER_TIMEOUT
130+ assert kwargs ["stdout" ] is sys .stderr
131+ assert kwargs ["stderr" ] is sys .stderr
129132
130133 def test_docker_pull_image_non_exist (self ):
131134 with patch (
@@ -149,11 +152,14 @@ def test_docker_pull_image_timeout(self):
149152 docker_pull_image ("ggshield-non-existant" , DOCKER_TIMEOUT )
150153
151154 def test_docker_pull_image_platform_fallback (self ):
152- with patch (
153- "subprocess.run" , side_effect = subprocess .CalledProcessError (1 , cmd = [])
154- ) as call , pytest .raises (
155- click .UsageError ,
156- match = 'Image "ggshield-non-existant" not found' ,
155+ with (
156+ patch (
157+ "subprocess.run" , side_effect = subprocess .CalledProcessError (1 , cmd = [])
158+ ) as call ,
159+ pytest .raises (
160+ click .UsageError ,
161+ match = 'Image "ggshield-non-existant" not found' ,
162+ ),
157163 ):
158164 docker_pull_image ("ggshield-non-existant" , DOCKER_TIMEOUT )
159165 call .assert_called_once_with (
@@ -171,18 +177,21 @@ def test_docker_save_image_success(self):
171177 docker_save_to_tmp (
172178 "ggshield-non-existant" , self .TMP_ARCHIVE , DOCKER_TIMEOUT
173179 )
174- call .assert_called_once_with (
180+ call .assert_called_once ()
181+ args , kwargs = call .call_args
182+ assert args == (
175183 [
176184 "docker" ,
177185 "save" ,
178186 "ggshield-non-existant:latest" ,
179187 "-o" ,
180188 str (self .TMP_ARCHIVE ),
181189 ],
182- check = True ,
183- stderr = - 1 ,
184- timeout = DOCKER_TIMEOUT ,
185190 )
191+ assert kwargs ["check" ] is True
192+ assert kwargs ["stderr" ] == subprocess .PIPE
193+ assert kwargs ["stdout" ] is sys .stderr
194+ assert kwargs ["timeout" ] == DOCKER_TIMEOUT
186195
187196 def test_docker_save_image_does_not_exist (self ):
188197 with patch (
0 commit comments