在Azure DevOps管道中运行PyTest任务会无限期挂起

时间:2019-09-10 01:07:14

标签: python azure-devops pytest azure-pipelines

我正在添加一个管道步骤来运行单元测试-测试套件很小,应该可以快速执行。但是,“运行PyTest”任务正在超时。我将超时设置为15分钟,这应该远远超过测试套件运行的时间(在IDE中运行它们需要2.5秒)

日志显示正在运行的最后一条命令是:

python.exe -m pytest --color=no -q --test-run-title="Unit Tests" --basetemp="D:\a\1\s" --junitprefix="py%winver%" --cov=test_module_A --cov=test_module_B --cov-report=xml --cov-report=html --pylint "D:\a\1\s\tests\test_module_A.py" "D:\a\1\s\tests\test_module_B.py"

我的Run PyTest任务的YAML:

steps:
- task: stevedower.python.PyTest.PyTest@2
  displayName: 'Run PyTest'
  inputs:
    title: 'Unit Tests'
    testroot: tests
    patterns: 'test_*.py'
    resultfile: tests
    doctests: false
    pylint: true
    codecoverage: 'test_module_A, test_module_B'
  timeoutInMinutes: 15

尽管正在运行pytest命令,但似乎并未真正执行测试。我不知道应该查看任何其他日志以获取更详细的测试运行信息。

2 个答案:

答案 0 :(得分:0)

我的测试是(我不知道)试图登录到Azure,因此测试运行挂在登录提示符处。确保模拟出Azure ML Workspace对象,而不仅仅是GetWorkspace()调用

答案 1 :(得分:0)

在相应的管道作业中,启用:

允许脚本访问OAuth令牌

为我解决了这个问题。