How to Run Tests Using uv

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

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 pytest

Running Tests Without Adding pytest as a Dependency

For quick testing without modifying your project dependencies:

uv run --with pytest pytest

Learn More

Last updated on

Please submit corrections and feedback...