我正在尝试使用“pytest”在 GitLab 中运行作业测试。 在项目中我使用诗歌,但在命令“诗歌安装”之后看不到已安装的库。错误:
pytest: command not found
我的*-gitlab-ci.yml:
stages:
- testing
test_job:
image: python:3.11-slim
stage: testing
script:
- 'apt-get update && apt-get install -y curl jq && curl -sSL https://install.python-
poetry.org | python3'
- 'PATH="$PATH:/root/.local/bin/"'
- 'poetry config virtualenvs.create false && poetry install'
- 'pytest tests'
在 Job 中,所有需要的东西都已安装,我稍后检查“poetry --version”/“python --version”,它们已就位,但 Python 库(pytest)给出错误。
我的 pyproject.toml:
[tool.poetry]
name = "pytestwithtesting"
version = "0.1.0"
description = "educational project"
authors = ["avtest <[email protected]>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.8"
pytest = "^8.2.2"
pyhamcrest = "^2.1.0"
cards = "^2.0.0"
allure-pytest = "^2.13.5"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
且项目结构较小:
pytestwithtesting-|
|- /tests
|-.gitlab-ci.yml
|- REAMDE.md
|- poetry.toml
|- pyproject.toml
请告诉我我可能错过了什么?
source .. activate
为我工作
- pip install -q poetry
- python -m poetry install --no-interaction
- source `poetry env info --path`/bin/activate