繁体   English   中英

Azure DevOps Pipeline 没有运行 Pytest. Keeps loading

[英]Azure DevOps Pipeline does not run Pytest. Keeps loading

我正面临一个奇怪的问题,我以前从未遇到过 Azure。

当我想运行管道并执行以下 bash 命令时:

echo 'Running unit tests'
pytest --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml

它什么都不做。 代理不断“加载”。 当我在本地运行 pytest 时,它会运行测试并通过它们。

任何人都知道问题可能是什么?

同样的 pytest 命令对我有效。

以下是我这边的一切。 你可以做一个测试来检查它是否对你有效。

bowmantest_module/初始化.py

#a module with +, -, *, / method

def add_bowman(a, b):
    return a + b

def sub_bowman(a, b):
    return a - b

def mul_bowman(a, b):
    return a * b

def div_bowman(a, b):
    return a / b

python_test.py

#a python unit test
import unittest
import bowmantest_module as btm

#+, -, *, / method in test class
class python_test(unittest.TestCase):
    def test_add(self):
        self.assertEqual(btm.add_bowman(1,1), 2)
    def test_sub(self):
        self.assertEqual(btm.sub_bowman(1,1), 0)
    def test_mul(self):
        self.assertEqual(btm.mul_bowman(1,1), 1)
    def test_div(self):
        self.assertEqual(btm.div_bowman(1,1), 1)

存储库结构:

在此处输入图像描述

azure-pipelines.yml

trigger:
- none

pool:
  vmImage: ubuntu-latest

steps:
- script: |
    pip install pytest
    pip install pytest-cov
  displayName: 'Install modules'
- script: |
    pytest --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml
    ls
  displayName: 'Run tests'

我可以成功得到结果:

在此处输入图像描述

我确定以上操作有效,如果仍然无效,我建议您检查代理池中的作业队列状态。 Microsoft Hosted Agent 在这个地方:

在此处输入图像描述

Microsoft Host Agent 仅为 DevOps 提供 1 个最多 1800 分钟/月的并行作业。 如果队列中有其他作业,则代理不会立即运行管道。

还要确保您没有超出管道并行作业的限制(总时间限制和并行作业限制。)。


顺便说一句,既然你在本地可以成功运行命令,那么你可以设置一个自托管代理,然后基于托管代理设计和运行管道,这样你就可以拥有与本地相同的环境。

暂无
暂无

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

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