如何指定在 tox 中使用哪个位置参数?
我有以下 tox.ini:
[tox]
envlist = py37-{lint, test}
[testenv:py37-{lint, test}]
envdir = {toxworkdir}/lint_and_test_env
deps =
pylint
pytest
pytest-xdist
commands =
lint: pylint src {posargs}
test: pytest tests {posargs}
我想并行运行两个环境,并为 pylint 指定 --jobs=4
,为 pytest 指定 -n auto
。执行 tox -p -- --jobs=4 -n auto 失败,因为 pylint 无法识别 -n 参数,反之亦然。
有办法实现我的目标吗?
I have the following tox.ini:
[tox]
envlist = py37-{lint, test}
[testenv:py37-{lint, test}]
envdir = {toxworkdir}/lint_and_test_env
deps =
pylint
pytest
pytest-xdist
commands =
lint: pylint src {posargs}
test: pytest tests {posargs}
I want to run both environments in parallel and specify --jobs=4
for pylint and -n auto
for pytest. Executing tox -p -- --jobs=4 -n auto
fails because pylint does not recognize the -n argument and vice versa.
Is there a way to achieve my goal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看不出有什么办法可以做你想做的事。
也就是说,我强烈建议您拆分环境并使用一个用于测试,另一个用于 linting。
然后,您可以向命令传递不同的参数,或通过 tox 运行所有环境。
如果您未指定
{posargs}
,您也可以设置默认值。例如,
如果您想并行运行所有
tox
env,您可以运行...PS:我是
tox
维护者之一,我为数百个开源项目做出了贡献项目,基本上 99% 使用单独的环境进行测试和 linting。PPS:如果您想运行多个 linter,您应该查看预提交。
I see no way to do what you want.
That said, I would strongly recommend that you split your environments and use one for testing and one for linting.
Then you can pass in different arguments to the commands, or run all envs via
tox
.Also you could set defaults in case you do not specify
{posargs}
.e.g.
If you want to run all
tox
envs in parallel you could run...P.S.: I am one of the
tox
maintainers, and I have contributed to hundreds of open source projects, and basically 99% use separate envs for testing and linting.P.P.S.: If you want to run more than one linter, you should have a look at pre-commit.