test_run_with_command_flags fails on macOS (BSD printenv doesn't support --version)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 88/100
Rechercherichtung
Beginne mit tests/test_cli.py::test_run_with_command_flags und untersuche, wie dort dotenv run printenv --version aufgerufen wird. Ersetze den betriebssystemspezifischen Sentinel durch den vorgeschlagenen Python-Befehl, der argv ausgibt, und führe diesen Test mit pytest oder tox auf macOS aus. Bestätige, dass die Assertion zur Weiterleitung der Flags erfolgreich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 8.9k
- Forks
- 600
- Ø Merge
- 4 T. 23 Std.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus theskumar/python-dotenv
-
An empty value ignores ${name:-default}Evtl. vergeben @SashaMIT hat das vor 10 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
theskumar/python-dotenv#715 ·
Maintainer antworten meist innerhalb von 1 Tag
-
set_key and unset_key don't fsync before replacing the .env fileEvtl. vergeben @Imkkey hat das vor 10 Tagen übernommen. Offenenhancement
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
theskumar/python-dotenv#713 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 28/100
theskumar/python-dotenv#693 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
python-dotenv installation without cli masks python-dotenv cliEvtl. vergeben @gyanu2507 hat das vor 49 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
theskumar/python-dotenv#683 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Feature Request: Automatically copy `default.env` to `.env`Evtl. vergeben @dradetsky hat das vor 159 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
theskumar/python-dotenv#644 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in theskumar/python-dotenv
Ähnliche Issues
-
docs pydanty:is-working
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
pydantic/pydantic-ai#10113 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
GreedyBear-Project/GreedyBear#1727 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
ARM-software/CMSIS-DSP#354 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
kiat/codeAssist#391 ·
-
needs triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
darnitdevorg/darnit#587 ·
Maintainer antworten meist innerhalb von 1 Tag