Pipenv Pipfile脚本中的bash条件



我有一个带有脚本的Pipfile

[script]
tests = "pytest --cov-fail-under=40 tests/"

我想让cov在参数值下失败取决于env变量。在Pipfile脚本之外,以下命令完成了任务:

pytest --cov-fail-under=$( case $VARin true ) echo 40 ;; * ) echo 80 ;; esac ) tests/

但当使用pipenv run tests执行时,bash条件显示为一个字符串,产生以下错误:

ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cov-fail-under: invalid validate_fail_under value: '$('

有什么解决办法吗?

您可以使用sh -c:生成shell

管道文件

[scripts]
tests = "sh -c '[ "${VAR}" = "true" ] && mincov=40 ; pytest --cov-fail-under="${mincov:-80}" tests'"

最新更新