簡體   English   中英

gitlab-ci.yml:“腳本:-pytest”命令無法識別

[英]gitlab-ci.yml: 'script: -pytest' command is not recognized

我無法在 Windows 上實現在 .gitlab-ci.yml 中運行 pytest 的示例程序:

使用 Shell 執行器...

請在下面找到 .gitlab-ci.yml:

# .gitlab-ci.yml

test_sample:
  stage: test
  tags: 
    - test_sam
  script:
    - echo "Testing"
    - pytest -s Target\tests 
  when: manual

CI/CD端子輸出:

pytest is not recognized as the name of a cmdlet, function, script file, or operable program.

Python 和 pytest 已安裝在運行測試的 Windows 操作系統上,但測試仍然失敗。 我已經嘗試了以下線程中建議的解決方案,但它不起作用: gitlab-ci.yml:'腳本:-pytest 找不到任何要檢查的測試'

您能否建議如何在 Windows 上通過此測試?

如果python被識別,你可以替換pytest ,就像這個類似的項目一樣:

unittests:
  script: python -m unittest discover tests -v
core doctests:
  script: python -m doctest -v AmpScan/core.py
registration doctests:
  script: python -m doctest -v AmpScan/registration.py
align doctests:
  script: python -m doctest -v AmpScan/align.py

初始切換到pytest失敗)

如果要使用 pytest,則需要在.gitlab.yml中使用 python Docker 映像。

請參閱Patrick Kennedy的“ 為 Python 應用程序設置 GitLab CI ”。

image: "python:3.7"

before_script:
  - python --version
  - pip install -r requirements.txt

stages:
  - Static Analysis
  - Test
...
unit_test:
  stage: Test
  script:
  - pwd
  - ls -l
  - export PYTHONPATH="$PYTHONPATH:."
  - python -c "import sys;print(sys.path)"
  - pytest

下面的命令沒有任何問題:

py -m pytest -s Target\tests

暫無
暫無

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

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