python - Microsoft azure devops python 管道失败,Bash 以代码“5”退出
问题描述
我正在关注https://docs.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python?view=azure-devops上的教程。
这是我的 azure-pipelines.yml 文件:
# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
strategy:
matrix:
Python27:
python.version: '2.7'
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
Python37:
python.version: '3.7'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'
- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'
- script: |
pip install pytest pytest-azurepipelines
pytest
displayName: 'pytest'
运行管道失败并显示以下错误消息。
Bash 以代码“5”退出。
我启用了系统诊断以将调试消息添加到日志中。
完整日志可在https://github.com/michaelhochleitner/debug-azure-devops-python-pipeline/blob/master/log.txt获得。
如何使管道运行而不会失败?
解决方案
如何使管道运行而不会失败?
同意phd,问题来了,因为可以收集0个测试项目。
从cewing检查这个详细的答案:
Pytest 根据命名约定收集测试。默认情况下,任何包含测试的文件都必须以 test_ 开头,并且文件中应被视为测试的任何函数也必须以 test_ 开头。
所以很明显pytest命令找不到任何xx.py
名称以.开头的文件test_
。所以对于 pytest,没有可用的测试,这会导致0 items collected
=> Bash exited with code '5'
。
我检查了你上面的教程并重现了同样的问题:
要解决它并使运行成功:
对我来说,我只是创建了一个新test_anyname.py
文件,其内容(test_xx.py
+ test_xx method
)如下:
然后我的管道在没有以下情况下成功运行Bash exited with code '5'
:
因此,您应该确保至少可以找到一个测试项目,并且错误会消失。希望能帮助到你 :)
推荐阅读
- javascript - 如何更改 mysql 数据库查询?
- javascript - 如何为 Tampermonkey 添加自定义指针?
- python - sklearn TfidfTransformer fit() 和 transform() 可以使用同一个源吗
- c - 使用 printf() 函数而不是 cout 的问题
- javascript - 检测某个文本是否是 JavaScript
- typescript - 打字稿枚举的vue v-for
- rust - 错误[E0277]:特征绑定`std::result::Result<_, Box
>: std::error::Error` 不满足 - python - 应该应用哪种技术来拆分大型文本数据集以进行数据匹配?
- android - Android/Jitpack:无法导入子模块
- c++ - std::trivially_copyable_v 和 std::is_pod_v (std::is_standard_layout && std::is_trivial_v) 有什么区别