Skip to content

Commit 9fa6fd9

Browse files
committed
Fix test_run_with_command_flags on macOS BSD printenv
The test used printenv --version to check that dotenv run forwards flags. GNU printenv accepts that flag; BSD printenv on macOS does not, so the suite fails even though flag forwarding works. Use the current Python interpreter's --version instead. Fixes #708
1 parent a00cb2e commit 9fa6fd9

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎tests/test_cli.py‎

Lines changed: 6 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

@@ -269,16 +270,18 @@ def test_run_with_command_flags(dotenv_path, tmp_path):
269270
"""
270271
Check that command flags passed after `dotenv run` are not interpreted.
271272
272-
Here, we want to run `printenv --version`, not `dotenv --version`.
273+
Use the current interpreter's ``--version`` so this stays portable: GNU
274+
printenv accepts ``--version``, but BSD printenv (macOS) does not.
273275
"""
274276

275277
result = run_dotenv(
276-
["--file", str(dotenv_path), "run", "printenv", "--version"],
278+
["--file", str(dotenv_path), "run", sys.executable, "--version"],
277279
cwd=tmp_path,
278280
)
279281

280282
check_process(result, exit_code=0)
281-
assert result.stdout.strip().startswith("printenv ")
283+
combined = (result.stdout + result.stderr).strip()
284+
assert combined.startswith("Python ")
282285

283286

284287
def test_run_with_dotenv_and_command_flags(dotenv_path, tmp_path):

0 commit comments

Comments
 (0)