Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte Adaptée aux débutants
#708 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
88/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python
Domaine
cli, testing

Piste de recherche

Commencez par tests/test_cli.py::test_run_with_command_flags et examinez comment il invoque dotenv run printenv --version. Remplacez le sentinel spécifique au système d’exploitation par la commande Python suggérée qui affiche argv, puis exécutez ce test avec pytest ou tox sur macOS et confirmez que l’assertion de transmission des flags réussit.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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
Langage dominant
Python
Étoiles
8.9k
Forks
585
Métriques de merge des PR
Aucune PR mergée en 30 j

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de theskumar/python-dotenv

Toutes les issues de theskumar/python-dotenv

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.