简体   繁体   English

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

[英]Run PyTest task in Azure DevOps pipeline hangs indefinitely

I am adding a pipeline step to run unit tests - the test suite is small and should execute quickly.我正在添加一个管道步骤来运行单元测试 - 测试套件很小并且应该快速执行。 However, the Run PyTest task is timing out.但是,Run PyTest 任务超时。 I set the timeout to 15 minutes which should be far more than enough time for the test suite to run (it takes 2.5 seconds for them to run in the IDE)我将超时设置为 15 分钟,这对于运行测试套件来说应该足够了(它们在 IDE 中运行需要 2.5 秒)

The logs show the last command being run is:日志显示正在运行的最后一个命令是:

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"

The YAML for my Run PyTest task:我的 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

It seems that the tests are not actually executing despite the pytest command being run.尽管 pytest 命令正在运行,但似乎测试实际上并未执行。 I am not aware of any additional logs that I should be looking at for more detailed test run information.我不知道我应该查看任何其他日志以获取更详细的测试运行信息。

My tests were (unbeknownst to me) attempting to log in to Azure, so the test run was hanging at the login prompt.我的测试(我不知道)试图登录到 Azure,因此测试运行在登录提示处挂起。 Be sure to mock out Azure ML Workspace object, not just the GetWorkspace() calls一定要模拟 Azure ML Workspace 对象,而不仅仅是 GetWorkspace() 调用

In the corresponding pipeline job, enabling:在相应的管道作业中,启用:

Allow scripts to access the OAuth token允许脚本访问 OAuth 令牌

Solved the issue for me.为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM