Skip to content

Commit 58f2d7c

Browse files
authored
test: make test_run_with_command_flags portable and meaningful (#709)
Fixes #708
1 parent e0310e5 commit 58f2d7c

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎tests/test_cli.py‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,24 @@ def test_run_with_command_flags(dotenv_path, tmp_path):
304304
"""
305305
Check that command flags passed after `dotenv run` are not interpreted.
306306
307-
Here, we want to run `printenv --version`, not `dotenv --version`.
307+
Here, we want the command to receive `--help`, not `dotenv run --help`.
308+
`sys.executable` is used instead of a system tool for portability.
308309
"""
309310

310311
result = run_dotenv(
311-
["--file", str(dotenv_path), "run", "printenv", "--version"],
312+
[
313+
"--file",
314+
str(dotenv_path),
315+
"run",
316+
sys.executable,
317+
"-c",
318+
"import sys; print(sys.argv[1:])",
319+
"--help",
320+
],
312321
cwd=tmp_path,
313322
)
314323

315-
check_process(result, exit_code=0)
316-
assert result.stdout.strip().startswith("printenv ")
324+
check_process(result, exit_code=0, stdout="['--help']\n")
317325

318326

319327
def test_run_with_dotenv_and_command_flags(dotenv_path, tmp_path):

0 commit comments

Comments
 (0)