File tree Expand file tree Collapse file tree 1 file changed +11
-18
lines changed
Expand file tree Collapse file tree 1 file changed +11
-18
lines changed Original file line number Diff line number Diff line change @@ -186,28 +186,21 @@ def test_run(tmp_path):
186186 with pushd (tmp_path ):
187187 (tmp_path / ".env" ).write_text ("a=b" )
188188
189- # Use sys.executable to run the command via Python directly
190189 if IS_WINDOWS :
191- # On Windows, use set command instead of echo with variable expansion
192- printenv_cmd = [
193- sys .executable ,
194- "-m" ,
195- "dotenv" ,
196- "run" ,
197- "cmd" ,
198- "/c" ,
199- "set" ,
200- "a" ,
201- ]
190+ # On Windows, use environment variables directly with the Python interpreter
191+ # Create a temporary batch file to source the environment and run Python
192+ batch_path = tmp_path / "run_test.bat"
193+ batch_path .write_text (
194+ f"@echo off\n dotenv run { sys .executable } -c \" import os; print(os.environ['a'])\" "
195+ )
196+
197+ # Run the batch file directly
198+ result = run_command (f"{ batch_path } " )
202199 else :
203200 printenv_cmd = ["dotenv" , "run" , "printenv" , "a" ]
201+ result = run_command (printenv_cmd )
204202
205- result = run_command (printenv_cmd )
206- if IS_WINDOWS :
207- # Windows 'set' command includes variable name, extract just the value
208- assert result .strip ().endswith ("=b" )
209- else :
210- assert result == "b\n "
203+ assert result .strip () == "b"
211204
212205
213206def test_run_with_existing_variable (tmp_path ):
You can’t perform that action at this time.
0 commit comments