[英]gitlab-ci.yml: 'script: -pytest' command is not recognized
I'm having trouble implementing an sample program that runs pytest within .gitlab-ci.yml on Windows:我无法在 Windows 上实现在 .gitlab-ci.yml 中运行 pytest 的示例程序:
Using Shell executor...使用 Shell 执行器...
Please find below .gitlab-ci.yml:请在下面找到 .gitlab-ci.yml:
# .gitlab-ci.yml
test_sample:
stage: test
tags:
- test_sam
script:
- echo "Testing"
- pytest -s Target\tests
when: manual
CI/CD terminal output: CI/CD端子输出:
pytest is not recognized as the name of a cmdlet, function, script file, or operable program.
Python and pytest is already installed on the Windows OS on which the test is running but still the test fails. Python 和 pytest 已安装在运行测试的 Windows 操作系统上,但测试仍然失败。 I have tried the solution suggested in below thread but it doesn't work: gitlab-ci.yml: 'script: -pytest cannot find any tests to check'
我已经尝试了以下线程中建议的解决方案,但它不起作用: gitlab-ci.yml:'脚本:-pytest 找不到任何要检查的测试'
Could you please suggest how to make this test pass on windows?您能否建议如何在 Windows 上通过此测试?
If python
is recognized, you could replace pytest
, as with this similar project , with:如果
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
(The initial switch to pytest
failed) ( 初始切换到
pytest
失败)
If you want to use pytest, you would need to use a python Docker image in your .gitlab.yml
.如果要使用 pytest,则需要在
.gitlab.yml
中使用 python Docker 映像。
See " Setting Up GitLab CI for a Python Application " from Patrick Kennedy .请参阅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.