Search code examples
python-poetrytox

Poetry & Tox: How to pass arguments to commands via Tox when running in Poetry


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!


Solution

  • -- is eaten by poetry so it runs tox \$username:\$password. To pass additional -- execute

    poetry run tox -- -- \$username:\$password