Skip to content

Commit 5542dde

Browse files
committed
try with 'set' instead 'echo'
1 parent de48f84 commit 5542dde

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

tests/test_cli.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
from pathlib import Path
34
from typing import Optional
45

@@ -238,14 +239,27 @@ def test_run_with_existing_variable_not_overridden(tmp_path):
238239
def test_run_with_none_value(tmp_path):
239240
with pushd(tmp_path):
240241
(tmp_path / ".env").write_text("a=b\nc")
242+
# Use sys.executable to run the command via Python directly
241243
if IS_WINDOWS:
242-
printenv_cmd = ["dotenv", "run", "cmd", "/c", "echo", "%a%"]
244+
printenv_cmd = [
245+
sys.executable,
246+
"-m",
247+
"dotenv",
248+
"run",
249+
"cmd",
250+
"/c",
251+
"set",
252+
"a",
253+
]
243254
else:
244255
printenv_cmd = ["dotenv", "run", "printenv", "a"]
245256

246257
result = run_command(printenv_cmd)
247-
248-
assert result == "b\n"
258+
if IS_WINDOWS:
259+
# Windows 'set' command includes variable name, extract just the value
260+
assert result.strip().endswith("=b")
261+
else:
262+
assert result == "b\n"
249263

250264

251265
def test_run_with_other_env(dotenv_path):

0 commit comments

Comments
 (0)