Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit eaed9ef5 authored by Dorian Turba's avatar Dorian Turba
Browse files

update pytest

parent 93ceb151
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,22 @@ Run [pytest](https://docs.pytest.org/en/latest/) on your Python code to ensure a
Pytest is a popular framework for writing and executing tests in Python, and it supports test
automation, modular fixtures, parameterized testing, and many other features.
### Global Configuration of pytest
## How to use it
1. Configure the `pytest.ini` or `pyproject.toml` file in your repository's root directory with your
desired rules.
2. Include the pytest template in your CI/CD configuration (see quick use above).
3. If you need to customize the job, check
the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization).
## Variables
| Name | Description | Default |
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------|
| `PYTHON_SETUP` | Bash commands to setup your python environment. Default rely on `pyproject.toml` to install project and test dependencies. | `"pip install .[TESTS]"` |
| `IMAGE_TAG` | The default tag for the docker image. See [Python Docker Official Image](https://hub.docker.com/_/python) for supported tags and respective Dockerfile links | `"latest"` |
## Global Configuration of pytest
To add configuration to `pytest` that is shared with any other usage of pytest (such as manual runs,
pre-commit, etc.), you can use the `pytest.ini` or `pyproject.toml` configuration files. Learn more
......@@ -34,14 +49,6 @@ testpaths = [
]
```
## How to use it
1. Configure the `pytest.ini` or `pyproject.toml` file in your repository's root directory with your
desired rules.
2. Include the pytest template in your CI/CD configuration (see quick use above).
3. If you need to customize the job, check
the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization).
## Change the Python version
By default, the template uses the latest Python version available in the image. If you need to
......@@ -49,10 +56,10 @@ change the Python version, you can override the docker image used in the templat
```yaml
stages:
- test
- test
include:
- remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/pytest@latest.yaml'
- remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba/r2devops_catalog/pytest@latest.yaml'
pytest:
image: python:3.11
......
pytest:
image: python:latest
image: python:${IMAGE_TAG}
stage: code_quality
variables:
PYTHON_SETUP: "pip install .[TESTS]"
IMAGE_TAG: "latest"
script:
- python --version # Debug
- python -m venv venv --upgrade-deps || python -m venv venv # upgrade-deps is not supported before 3.9
- source venv/bin/activate
- pip install pytest
- ${PYTHON_SETUP}
- pytest
only:
changes:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment