pythonpytestuv

How to run tests using each package pyproject.toml configuration instead of the top level pyproject.toml?


I'm using uv workspace with a structure that looks like the following example from the doc.

albatross
├── packages
│   ├── bird-feeder
│   │   ├── pyproject.toml
│   │   └── src
│   │       └── bird_feeder
│   │           ├── __init__.py
│   │           └── foo.py
│   └── seeds
│       ├── pyproject.toml
│       └── src
│           └── seeds
│               ├── __init__.py
│               └── bar.py
├── pyproject.toml
├── README.md
├── uv.lock
└── src
    └── albatross
        └── main.py

How do I tell pytest to use the configuration in each package pyproject.toml while running pytest from the root package(albatross in this case) directory?


Solution

  • You can tell pytest the directory:

    uv run pytest packages/bird-feeder
    

    uv run --package bird-feeder doesn't work:

    uv run --directory packages/bird-feeder works:

    uv run --directory packages/bird-feeder pytest
    

    Related: Using uv run as a task runner #5903 may be supported in future.