Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

test_run_with_command_flags fails on macOS (BSD printenv doesn't support --version)

Aperta Adatta ai principianti
#708 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
cli, testing

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, printenv is GNU coreutils' version, which supports --version and exits 0.
  • On macOS, printenv is the BSD version, which does not support --version at all, and exits 1 with printenv: 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 tox locally
  • Reproducible with plain pytest too, since it's just calling the system printenv
Lingua principale
Python
Stelle
8.9k
Fork
585
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di theskumar/python-dotenv

Tutte le issue di theskumar/python-dotenv

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.