@@ -51,11 +51,16 @@ def __init__(
5151 },
5252 )
5353
54- def exec_cmd_stream (self , command ):
54+ def exec_cmd_stream (self , command , verbose = True ):
5555 """Execute a command and stream output."""
56- _ , stream = self .container .exec_run (cmd = command , stream = True )
56+ exec_id = self .container .client .api .exec_create (self .container .id , command )
57+ stream = self .container .client .api .exec_start (exec_id , stream = True )
5758 for data in stream :
58- print (data .decode (), end = "" )
59+ if verbose :
60+ print (data .decode (), end = "" )
61+ result = self .container .client .api .exec_inspect (exec_id )["ExitCode" ]
62+ if result != 0 :
63+ exit (1 )
5964
6065 def exec_cmd (self , command , verbose = True ):
6166 """Execute a command and validate return code."""
@@ -130,9 +135,11 @@ def remove(self):
130135 )
131136 cmd = "sh -c 'python tools/tests.py -u $USERNAME -p $PASSWORD -c $CONFIG"
132137 if args ["module" ] == "local" :
133- testcontainers .exec_cmd ("pip install ." , args ["verbose" ])
138+ testcontainers .exec_cmd_stream ("pip install .[develop]" , args ["verbose" ])
139+ print ("Running black, flake8, isort and pyright:" )
140+ testcontainers .exec_cmd_stream ("tools/validate.sh" , args ["verbose" ])
134141 else :
135- testcontainers .exec_cmd (
142+ testcontainers .exec_cmd_stream (
136143 "pip install pye3dc=={}" .format (args ["module" ]), args ["verbose" ]
137144 )
138145 cmd = cmd + " -m"
@@ -144,5 +151,5 @@ def remove(self):
144151 cmd = cmd + " -v'"
145152 else :
146153 cmd = cmd + "'"
147- testcontainers .exec_cmd (cmd )
154+ testcontainers .exec_cmd_stream (cmd )
148155 testcontainers .remove ()
0 commit comments