[英]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.