英文:
Poetry & Tox: How to pass arguments to commands via Tox when running in Poetry
问题
当我尝试通过 Poetry 中的 Tox v4.2.6 传递参数给一个命令时,它无法识别 --
作为分隔符。
命令:
poetry run tox -- $username:$password
Tox 错误:
tox: error: 无法识别的参数: $username:$password
提示: 如果您尝试传递参数给一个命令,请使用 -- 将它们与 tox 的参数分开
当我在 Poetry 外部运行相同的 Tox 命令时,它按预期工作 (tox -- \$username:\$password
)。
有谁知道我漏掉了什么吗?
我的 tox.ini
文件如下:
[tox]
envlist = py39,lint,bandit
isolated_build = True
toxworkdir = {toxinidir}/build/tox
[base]
setenv =
PIP_INDEX_URL = https://{posargs}@blah.artifactory.com/artifactory/api/pypi/pypi-blah-prod-virtual/simple
[testenv]
setenv =
{[base]setenv}
deps =
pytest
pyyaml
commands = pytest --junitxml=junit-{envname}.xml
英文:
When I try to pass an argument to a command via Tox v4.2.6 within Poetry it is failing to recognise --
as a separator.
Command:
poetry run tox -- $username:$password
Tox error:
tox: error: unrecognized arguments: $username:$password
hint: if you tried to pass arguments to a command use -- to separate them from tox ones
When I run the same Tox command outside of Poetry it works as expected (tox -- \$username:\$password
)
Does anyone know what I am missing?
my tox.ini
is:
[tox]
envlist = py39,lint,bandit
isolated_build = True
toxworkdir = {toxinidir}/build/tox
[base]
setenv =
PIP_INDEX_URL =
https://{posargs}@blah.artifactory.com/artifactory/api/pypi/pypi-blah-prod-virtual/simple
[testenv]
setenv =
{[base]setenv}
deps =
pytest
pyyaml
commands = pytest --junitxml=junit-{envname}.xml
Thanks!
答案1
得分: 4
--
被 Poetry 吃掉,所以它运行 tox \$username:\$password
。要传递额外的 --
,执行以下命令:
poetry run tox -- -- $username:$password
英文:
--
is eaten by poetry so it runs tox \$username:\$password
. To pass additional --
execute
poetry run tox -- -- $username:$password
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论