@@ -47,13 +47,18 @@ def check_output(cmd, encoding=None):
4747    p  =  subprocess .Popen (cmd ,
4848        stdout = subprocess .PIPE ,
4949        stderr = subprocess .PIPE ,
50-         encoding = encoding )
50+         env = { ** os . environ ,  "PYTHONHOME" :  "" } )
5151    out , err  =  p .communicate ()
5252    if  p .returncode :
5353        if  verbose  and  err :
54-             print (err .decode ('utf-8' , 'backslashreplace' ))
54+             print (err .decode (encoding   or   'utf-8' , 'backslashreplace' ))
5555        raise  subprocess .CalledProcessError (
5656            p .returncode , cmd , out , err )
57+     if  encoding :
58+         return  (
59+             out .decode (encoding , 'backslashreplace' ),
60+             err .decode (encoding , 'backslashreplace' ),
61+         )
5762    return  out , err 
5863
5964class  BaseTest (unittest .TestCase ):
@@ -273,8 +278,18 @@ def test_sysconfig(self):
273278            ('get_config_h_filename()' , sysconfig .get_config_h_filename ())):
274279            with  self .subTest (call ):
275280                cmd [2 ] =  'import sysconfig; print(sysconfig.%s)'  %  call 
276-                 out , err  =  check_output (cmd )
277-                 self .assertEqual (out .strip (), expected .encode (), err )
281+                 out , err  =  check_output (cmd , encoding = 'utf-8' )
282+                 self .assertEqual (out .strip (), expected , err )
283+         for  attr , expected  in  (
284+             ('executable' , self .envpy ()),
285+             # Usually compare to sys.executable, but if we're running in our own 
286+             # venv then we really need to compare to our base executable 
287+             ('_base_executable' , sys ._base_executable ),
288+         ):
289+             with  self .subTest (attr ):
290+                 cmd [2 ] =  f'import sys; print(sys.{ attr }  )' 
291+                 out , err  =  check_output (cmd , encoding = 'utf-8' )
292+                 self .assertEqual (out .strip (), expected , err )
278293
279294    @requireVenvCreate  
280295    @unittest .skipUnless (can_symlink (), 'Needs symlinks' ) 
@@ -296,8 +311,18 @@ def test_sysconfig_symlinks(self):
296311            ('get_config_h_filename()' , sysconfig .get_config_h_filename ())):
297312            with  self .subTest (call ):
298313                cmd [2 ] =  'import sysconfig; print(sysconfig.%s)'  %  call 
299-                 out , err  =  check_output (cmd )
300-                 self .assertEqual (out .strip (), expected .encode (), err )
314+                 out , err  =  check_output (cmd , encoding = 'utf-8' )
315+                 self .assertEqual (out .strip (), expected , err )
316+         for  attr , expected  in  (
317+             ('executable' , self .envpy ()),
318+             # Usually compare to sys.executable, but if we're running in our own 
319+             # venv then we really need to compare to our base executable 
320+             ('_base_executable' , sys ._base_executable ),
321+         ):
322+             with  self .subTest (attr ):
323+                 cmd [2 ] =  f'import sys; print(sys.{ attr }  )' 
324+                 out , err  =  check_output (cmd , encoding = 'utf-8' )
325+                 self .assertEqual (out .strip (), expected , err )
301326
302327    if  sys .platform  ==  'win32' :
303328        ENV_SUBDIRS  =  (
0 commit comments