簡體   English   中英

在 Azure DevOps 管道中找不到 Pytest

[英]Pytest not found in Azure DevOps Pipeline

在我的 Azure DevOps 管道中

( https://dev.azure.com/TheNewThinkTank/dark-matter-attractor/_build?definitionId=2&_a=summary )

我有一個測試階段,我希望在相應的 Azure DevOps 存儲庫中的所有 Python 文件上安裝和運行 pytest

https://dev.azure.com/TheNewThinkTank/_git/dark-matter-attractor )。

Pytest的安裝運行方式遵循微軟官方文檔:

- script: |
    pip install pytest
    pip install pytest-cov
    pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
  displayName: 'Test with pytest'

可以在以下位置找到: https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/python?view=azure-devops

運行 Pipeline 導致上述步驟報錯: pytest: command not found

如果你想看到完整的回溯:

https://dev.azure.com/TheNewThinkTank/dark-matter-attractor/_build/results?buildId=62&view=logs&j=792982d5-3bb1-5d82-222e-228148b73448&t=1f7e9bd0b0b-31cdf7-9

我嘗試過的其他事情:

按照官方 pytest 站點( https://docs.pytest.org/en/stable/getting-started.html ),我嘗試在安裝命令中添加一個標志: pip install -U pytest

是什么阻止管道發現已安裝的 pytest 模塊?

請嘗試python -m pytest

- script: |
    pip install pytest
    pip install pytest-cov
    python -m pytest tests --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml --cov-report=html
  displayName: 'Test with pytest'

安裝在 pip 上的模塊不被識別為系統級命令。

@Krzysztof Madej,當前目錄未作為 PYTHONPATH 加載,因此出現模塊未找到錯誤

 /usr/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_cfn_params_handler.py:17: in <module>
    from manifest.cfn_params_handler import CFNParamsHandler
E   ModuleNotFoundError: No module named 'manifest'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM