Skip to content

Kickgodx/python-pytest

Repository files navigation

Petstore API tests

Python pytest pytest-xdist Allure-pytest

🔍 Latest Test Results

Installation

  1. Clone the repository
  2. Install the required packages using the following command:
pip install -r requirements.txt

Running the tests

To run the tests, use the following command:

pytest

Parallel execution with pytest-xdist

To run the tests in parallel, use the following command:

pytest -n <number_of_workers>

Allure report

Pytest generates an Allure report after running the tests. To view the report, use the following command:

allure serve allure-results

Test cases

The test cases are located in the tests directory. Pull of the test cases are located in the file.

Structure

The repository has the following structure:

  • tests: Contains the test cases
  • src: Contains the functions that are used in the tests (api, helpers, assertions, etc.)
  • allure-results: Contains the Allure report results
  • requirements.txt: Contains the required packages
  • pytest.ini: Contains the pytest configuration
  • README.md: Contains the repository description
  • .gitignore: Contains the files and directories that are ignored by Git
  • docker-compose.yml: Contains the Docker Compose configuration
  • Dockerfile: Contains the Docker configuration

Docker

To run the tests in a Docker container, use the following command:

docker-compose up

or

docker build -t petstore-api-tests .
docker run petstore-api-tests

Pre-commit

To run pre-commit hooks from .pre-commit-config.yaml, use the following command:

pre-commit run --all-files

Linters

ruff, black, isort with pyproject.toml config

  • ruff: ruff check .
  • black: black .
  • isort: isort .

automatically fix with --fix flag

  • ruff: ruff --fix .

Docstrings check

Interrogate can be added to the pre-commit hooks to check for docstrings in the code.

To run Interrogate solo, use the following command:

- `interrogate -v -e .\tests\ .`

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •