如何通过Poetry在Tox中传递命令参数

huangapple go评论50阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年1月9日 19:04:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75056352.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定