File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 66import  shutil 
77import  stat 
88import  sys 
9+ from  unittest .mock  import  patch 
910
1011# Submodules 
1112import  payu 
@@ -327,20 +328,22 @@ def test_run_userscript_python_script_with_shebang_header(tmp_path):
327328    with  open (python_script , 'w' ) as  f :
328329        f .writelines ([
329330            '#!/usr/bin/env python\n ' 
331+             'import sys\n ' 
330332            f"with open('{ tmp_path } \n " ,
331-             "   f.write('Test Python user script with python shebang header ')" 
333+             "   f.write(f'{sys.executable} ')" 
332334        ])
333335
334336    # Make file executable 
335337    os .chmod (python_script , 0o775 )
336338
337339    # Test run userscript 
338-     payu .fsops .run_script_command ('test_script_with_python_shebang.py' ,
339-                                   tmp_path )
340+     with  patch .dict (os .environ , {'PATH' : '/mocked/path' }):
341+         payu .fsops .run_script_command ('test_script_with_python_shebang.py' ,
342+                                       tmp_path )
340343
341-     # Check script output  
344+     # Check script is run with same python executable as caller  
342345    with  open ((tmp_path  /  'output.txt' ), 'r' ) as  f :
343-         assert  f .read ()  ==   "Test Python user script with python shebang header" 
346+         assert  sys . executable . startswith ( f .read ()) 
344347
345348
346349def  test_run_userscript_bash_script (tmp_path ):
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments