Pytest
A powerful framework for testing Python code, supporting both synchronous and asynchronous tests.
What is it used for here?
!
unit testing
andintegration testing
of Python code- testing both synchronous and asynchronous functions
- automated quality checks before every commit and in CI pipelines
Important
!
- For testing asynchronous functions, the pytest-asyncio extension is added, which makes it easy to write and run async tests alongside regular ones.
How to use it?
- In this case, the Makefile does the same as running the commands directly via uv. The Makefile is only needed to shorten commands.
How to use it with pre-commit?
Only a local hook is used for integration with pre-commit.
Why?
Pytest does not officially provide a pre-commit hook repository, and running tests often requires custom parameters or environments (for example, via uv or with specific options). A local hook gives maximum flexibility and control.
!
Configuration
All configuration for Pytest (such as plugins) in this template is located in pyproject.toml under the [tool.pytest.ini_options]
section.
For more details on configuration, see the Pytest Documentation
About async tests: pytest-asyncio documentation