How to Run Tests Using uv
by Tim Hopper
This guide shows you how to use uv to run tests in your Python projects efficiently.
Note
While this guide focuses on pytest, pytest can discover and run tests written for various Python testing frameworks, including unittest, nose, and doctest.
Prerequisites
- uv installed on your system
- A Python project with test files
Running Tests in an Existing Project
Basic Test Execution
If your project already has pytest configured as a dependency, run your tests with:
uv run pytestRunning Tests Without Adding pytest as a Dependency
For quick testing without modifying your project dependencies:
uv run --with pytest pytestLearn More
- Setting up testing with pytest and uv for a complete testing setup
- How to test against multiple Python versions using uv for running tests across Python versions
- How to fix common pytest errors with uv for troubleshooting ModuleNotFoundError and other issues
Get Python tooling updates
Subscribe to the newsletterLast updated on