@@ -128,7 +128,7 @@ def test_basic_run(self, tmp_path: Path) -> None:
128128 logger = MagicMock (), session_working_directory = tmp_path , callback = callback
129129 ) as runner :
130130 # WHEN
131- runner ._run ([sys .executable , "-c" , "import time; time.sleep(0.25)" ])
131+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , "-c" , "import time; time.sleep(0.25)" ])
132132
133133 # THEN
134134 assert runner .state == ScriptRunnerState .RUNNING
@@ -173,7 +173,7 @@ def test_working_dir_is_cwd(
173173 logger = logger , session_working_directory = tmp_path , startup_directory = tmp_path
174174 ) as runner :
175175 # WHEN
176- runner ._run ([sys .executable , "-c" , "import os; print(os.getcwd())" ])
176+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , "-c" , "import os; print(os.getcwd())" ])
177177 # Wait until the process exits.
178178 while runner .state == ScriptRunnerState .RUNNING :
179179 time .sleep (0.1 )
@@ -189,7 +189,7 @@ def test_failing_run(self, tmp_path: Path) -> None:
189189 # GIVEN
190190 with TerminatingRunner (logger = MagicMock (), session_working_directory = tmp_path ) as runner :
191191 # WHEN
192- runner ._run ([sys .executable , "-c" , "import sys; sys.exit(1)" ])
192+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , "-c" , "import sys; sys.exit(1)" ])
193193
194194 # THEN
195195 while runner .state == ScriptRunnerState .RUNNING :
@@ -256,7 +256,7 @@ def test_run_with_env_vars(
256256 # WHEN
257257 runner ._run (
258258 [
259- sys .executable ,
259+ sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) ,
260260 "-c" ,
261261 r"import os;print(*(f'{k} = {v}' for k,v in os.environ.items()), sep='\n')" ,
262262 ]
@@ -297,8 +297,8 @@ def test_run_as_posix_user(
297297 # WHEN
298298 runner ._run (
299299 [
300- # Note: Intentionally not `sys.executable`. Reasons:
301- # 1) This is a cross-account command, and sys.executable may be in a user-specific venv
300+ # Note: Intentionally not `sys.executable.lower().replace("pythonservice.exe", "python.exe") `. Reasons:
301+ # 1) This is a cross-account command, and sys.executable.lower().replace("pythonservice.exe", "python.exe") may be in a user-specific venv
302302 # 2) This test is, generally, intended to be run in a docker container where the system
303303 # python is the correct version that we want to run under.
304304 "python" ,
@@ -348,8 +348,8 @@ def test_run_as_posix_user_with_env_vars(
348348 # WHEN
349349 runner ._run (
350350 [
351- # Note: Intentionally not `sys.executable`. Reasons:
352- # 1) This is a cross-account command, and sys.executable may be in a user-specific venv
351+ # Note: Intentionally not `sys.executable.lower().replace("pythonservice.exe", "python.exe") `. Reasons:
352+ # 1) This is a cross-account command, and sys.executable.lower().replace("pythonservice.exe", "python.exe") may be in a user-specific venv
353353 # 2) This test is, generally, intended to be run in a docker container where the system
354354 # python is the correct version that we want to run under.
355355 "python" ,
@@ -467,8 +467,8 @@ def test_run_as_windows_user_with_env_vars(
467467 # WHEN
468468 runner ._run (
469469 [
470- # Note: Intentionally not `sys.executable`. Reasons:
471- # 1) This is a cross-account command, and sys.executable may be in a user-specific venv
470+ # Note: Intentionally not `sys.executable.lower().replace("pythonservice.exe", "python.exe") `. Reasons:
471+ # 1) This is a cross-account command, and sys.executable.lower().replace("pythonservice.exe", "python.exe") may be in a user-specific venv
472472 # 2) This test is, generally, intended to be run in a docker container where the system
473473 # python is the correct version that we want to run under.
474474 "python" ,
@@ -518,8 +518,8 @@ def test_does_not_inherit_env_vars_posix(
518518 # WHEN
519519 runner ._run (
520520 [
521- # Note: Intentionally not `sys.executable`. Reasons:
522- # 1) This is a cross-account command, and sys.executable may be in a user-specific venv
521+ # Note: Intentionally not `sys.executable.lower().replace("pythonservice.exe", "python.exe") `. Reasons:
522+ # 1) This is a cross-account command, and sys.executable.lower().replace("pythonservice.exe", "python.exe") may be in a user-specific venv
523523 # 2) This test is, generally, intended to be run in a docker container where the system
524524 # python is the correct version that we want to run under.
525525 "python" ,
@@ -570,8 +570,8 @@ def test_does_not_inherit_env_vars_windows(
570570 ) as runner :
571571 # WHEN
572572 py_script = f"import os; v=os.environ.get('{ var_name } '); print('NOT_PRESENT' if v is None else v)"
573- # Use the default 'python' rather than 'sys.executable' since we typically do not have access to
574- # sys.executable when running with impersonation since it's in a hatch environment for the local user.
573+ # Use the default 'python' rather than 'sys.executable.lower().replace("pythonservice.exe", "python.exe") ' since we typically do not have access to
574+ # sys.executable.lower().replace("pythonservice.exe", "python.exe") when running with impersonation since it's in a hatch environment for the local user.
575575 runner ._run (["python" , "-c" , py_script ])
576576
577577 # THEN
@@ -598,11 +598,11 @@ def test_cannot_run_twice(self, tmp_path: Path) -> None:
598598 logger = MagicMock (), session_working_directory = tmp_path , callback = callback
599599 ) as runner :
600600 # WHEN
601- runner ._run ([sys .executable , "-c" , "print('hello')" ])
601+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , "-c" , "print('hello')" ])
602602
603603 # THEN
604604 with pytest .raises (RuntimeError ):
605- runner ._run ([sys .executable , "-c" , "print('hello')" ])
605+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , "-c" , "print('hello')" ])
606606
607607 @pytest .mark .usefixtures ("message_queue" , "queue_handler" )
608608 def test_run_action (
@@ -623,7 +623,7 @@ def test_run_action(
623623 python_app_loc = (Path (__file__ ).parent / "support_files" / "app_20s_run.py" ).resolve ()
624624 symtab = SymbolTable (
625625 source = {
626- "Task.PythonInterpreter" : sys .executable ,
626+ "Task.PythonInterpreter" : sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) ,
627627 "Task.ScriptFile" : str (python_app_loc ),
628628 }
629629 )
@@ -683,7 +683,7 @@ def test_run_action_default_timeout(
683683 python_app_loc = (Path (__file__ ).parent / "support_files" / "app_20s_run.py" ).resolve ()
684684 symtab = SymbolTable (
685685 source = {
686- "Task.PythonInterpreter" : sys .executable ,
686+ "Task.PythonInterpreter" : sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) ,
687687 "Task.ScriptFile" : str (python_app_loc ),
688688 }
689689 )
@@ -755,7 +755,7 @@ def test_cancel_terminate(
755755 logger = logger , session_working_directory = tmp_path , callback = callback
756756 ) as runner :
757757 python_app_loc = (Path (__file__ ).parent / "support_files" / "app_20s_run.py" ).resolve ()
758- runner ._run ([sys .executable , str (python_app_loc )])
758+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , str (python_app_loc )])
759759
760760 # WHEN
761761 runner .cancel ()
@@ -789,7 +789,7 @@ def test_run_with_time_limit(
789789 python_app_loc = (Path (__file__ ).parent / "support_files" / "app_20s_run.py" ).resolve ()
790790
791791 # WHEN
792- runner ._run ([sys .executable , str (python_app_loc )], time_limit = timedelta (seconds = 1 ))
792+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , str (python_app_loc )], time_limit = timedelta (seconds = 1 ))
793793
794794 # THEN
795795 # Wait until the process exits. We'll be in CANCELING state between when the timeout is reached
@@ -818,7 +818,7 @@ def test_cancel_notify(
818818 python_app_loc = (
819819 Path (__file__ ).parent / "support_files" / "app_20s_run_ignore_signal.py"
820820 ).resolve ()
821- runner ._run ([sys .executable , str (python_app_loc )])
821+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , str (python_app_loc )])
822822
823823 # WHEN
824824 secs = 2 if not is_windows () else 5
@@ -971,7 +971,7 @@ def test_cancel_double_cancel_notify(
971971 python_app_loc = (
972972 Path (__file__ ).parent / "support_files" / "app_20s_run_ignore_signal.py"
973973 ).resolve ()
974- runner ._run ([sys .executable , str (python_app_loc )])
974+ runner ._run ([sys .executable . lower (). replace ( "pythonservice.exe" , "python.exe" ) , str (python_app_loc )])
975975
976976 # WHEN
977977 secs = 2 if not is_windows () else 5
0 commit comments