test_run_with_command_flags fails on macOS (BSD printenv doesn't support --version)
Mantenedores costumam responder em até 12 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 88/100
Direção de pesquisa
Comece por tests/test_cli.py::test_run_with_command_flags e inspecione como ele invoca dotenv run printenv --version. Substitua o sentinel específico do sistema operacional pelo comando Python sugerido que exibe argv e execute esse teste com pytest ou tox no macOS para confirmar que a asserção de encaminhamento de flags passa.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- Python
- Estrelas
- 8.9k
- Forks
- 585
- Merge médio
- 11d 5h
- PRs com merge (30d)
- 2
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de theskumar/python-dotenv
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
theskumar/python-dotenv#699 · 1 comentário ·
Mantenedores costumam responder em até 12 dias
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 78/100
theskumar/python-dotenv#710 ·
Mantenedores costumam responder em até 12 dias
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 28/100
theskumar/python-dotenv#693 · 1 comentário ·
Mantenedores costumam responder em até 12 dias
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
theskumar/python-dotenv#683 · 4 comentários ·
Mantenedores costumam responder em até 12 dias
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
theskumar/python-dotenv#644 · 2 comentários ·
Mantenedores costumam responder em até 12 dias
Todas as issues de theskumar/python-dotenv
Issues semelhantes
-
bug server
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
sportsdataverse/sportsdataverse-py#641 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
googleapis/google-cloud-python#18532 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia