@@ -285,15 +285,27 @@ def test_with_pip(self):
285285 # warnings in current versions of Python. Ensure related
286286 # environment settings don't cause venv to fail.
287287 envvars ["PYTHONWARNINGS" ] = "e"
288- self .run_with_capture (venv .create , self .env_dir , with_pip = True )
288+ try :
289+ self .run_with_capture (venv .create , self .env_dir , with_pip = True )
290+ except subprocess .CalledProcessError as exc :
291+ # The output this produces can be a little hard to read, but
292+ # least it has all the details
293+ details = exc .output .decode (errors = "replace" )
294+ msg = "{}\n \n **Subprocess Output**\n {}" .format (exc , details )
295+ self .fail (msg )
289296 envpy = os .path .join (os .path .realpath (self .env_dir ), self .bindir , self .exe )
290297 cmd = [envpy , '-m' , 'pip' , '--version' ]
291298 p = subprocess .Popen (cmd , stdout = subprocess .PIPE ,
292299 stderr = subprocess .PIPE )
293300 out , err = p .communicate ()
294- self .assertEqual (err , b"" )
295- self .assertTrue (out .startswith (b"pip" ))
296- self .assertIn (self .env_dir .encode (), out )
301+ # We force everything to text, so unittest gives the detailed diff
302+ # if we get unexpected results
303+ err = err .decode ("latin-1" ) # Force to text, prevent decoding errors
304+ self .assertEqual (err , "" )
305+ out = out .decode ("latin-1" ) # Force to text, prevent decoding errors
306+ env_dir = os .fsencode (self .env_dir ).decode ("latin-1" )
307+ self .assertTrue (out .startswith ("pip" ))
308+ self .assertIn (env_dir , out )
297309
298310
299311def test_main ():
0 commit comments