test_run_with_command_flags fails on macOS (BSD printenv doesn't support --version)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 88/100
Direzione di ricerca
Inizia da tests/test_cli.py::test_run_with_command_flags e verifica come invoca dotenv run printenv --version. Sostituisci il sentinel specifico del sistema operativo con il comando Python suggerito che visualizza argv, quindi esegui questo test con pytest o tox su macOS e conferma che l’assertion sull’inoltro dei flags vada a buon fine.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
tests/test_cli.py::test_run_with_command_flags fails when running the test suite (via tox or pytest) on macOS.
tests/test_cli.py::test_run_with_command_flags FAILED
AssertionError: Unexpected exit code 1 (expected 0)
stdout:
stderr:
printenv: illegal option -- -
usage: printenv [name]
assert 1 == 0
Root cause
The test runs dotenv run printenv --version and asserts it exits 0, to verify that dotenv run forwards flags to the wrapped command instead of parsing them itself (added in #607 / #612).
- On Linux,
printenvis GNU coreutils' version, which supports--versionand exits 0. - On macOS,
printenvis the BSD version, which does not support--versionat all, and exits 1 withprintenv: illegal option -- -.
So the test is actually working as intended (dotenv run correctly passes --version straight through to printenv rather than swallowing it), but the assertion only holds on systems with GNU printenv.
Why this hasn't been caught in CI
.github/workflows/test.yml only runs the test matrix on ubuntu-latest and windows-latest - there's no macos-latest job, so this has never surfaced there.
CONTRIBUTING.md tells contributors to just run tox or pytest, with no mention that the suite assumes a GNU userland / Linux, so a macOS contributor following the documented steps hits this with no explanation.
Suggested fix
Replace the OS-specific sentinel command (printenv --version) with something that behaves identically across GNU/BSD/Windows, e.g. a small python -c "..." snippet that just echoes its argv, so the test only cares about flag-forwarding behavior rather than a specific external tool's flag parsing.
Environment
- macOS (Darwin), tested via
toxlocally - Reproducible with plain
pytesttoo, since it's just calling the systemprintenv
- Lingua principale
- Python
- Stelle
- 8.9k
- Fork
- 585
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di theskumar/python-dotenv
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
theskumar/python-dotenv#699 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
theskumar/python-dotenv#697 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
theskumar/python-dotenv#693 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
theskumar/python-dotenv#683 · 4 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
theskumar/python-dotenv#644 · 2 commenti ·
Tutte le issue di theskumar/python-dotenv
Issue simili
-
Claiming namespace `apoint`Apertanamespace operations
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
EclipseFdn/open-vsx.org#13573 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
collective/icalendar#1854 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rancher/rancher-ai-agent#412 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TUDelftGeodesy/DePSI#134 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
HenriquesLab/rxiv-maker#335 ·