# Alexis Challande - Making PyPI's Test Suite 81% Faster (Highlights)

## Metadata
**Review**:: [readwise.io](https://readwise.io/bookreview/51343391)
**Source**:: #from/readwise #from/reader
**Zettel**:: #zettel/fleeting
**Status**:: #x
**Authors**:: [[Alexis Challande]]
**Full Title**:: Making PyPI's Test Suite 81% Faster
**Category**:: #articles #readwise/articles
**Category Icon**:: 📰
**URL**:: [blog.trailofbits.com](https://blog.trailofbits.com/2025/05/01/making-pypis-test-suite-81-faster/)
**Host**:: [[blog.trailofbits.com]]
**Highlighted**:: [[2025-05-12]]
**Created**:: [[2025-05-14]]
## Highlights
- We implemented parallel test execution using [`pytest-xdist`](https://github.com/pytest-dev/pytest-xdist), a popular plugin that distributes tests across multiple CPU cores. ([View Highlight](https://read.readwise.io/read/01jv1ny9vszkc54rtx7kqd3x3z)) ^888634106
- Each test worker needed its isolated database instance to prevent cross-test contamination. ([View Highlight](https://read.readwise.io/read/01jv1nznhx82bdy6dwzqgrwkr0)) ^888634163
Use decorator `@pytest.fixture(scope="session")`
- Parallel execution produced interleaved, difficult-to-read output. We integrated [pytest-sugar](https://github.com/Teemu/pytest-sugar) to provide cleaner, more organized test results ([PR #16245](https://github.com/pypi/warehouse/pull/16245)). ([View Highlight](https://read.readwise.io/read/01jv1p15jz0qyw40z974eh4jxk)) ^888634205
- In Python 3.12 and above, you can try an experimental core based on the new `sys.monitoring module` by defining a `COVERAGE_CORE=sysmon` environment variable. This should be faster, though plugins and dynamic contexts are not yet supported with it. ([View Highlight](https://read.readwise.io/read/01jv1p25w21gapkt0tmxzm8evn)) ^888634257
- Warehouse tests are all located in a single directory structure, making them ideal candidates for a powerful `pytest` configuration option: [`testpaths`](https://docs.pytest.org/en/stable/reference/reference.html#confval-testpaths). This simple one-line change instructs `pytest` to look for tests only in the specified directory, eliminating wasted effort scanning irrelevant paths ([View Highlight](https://read.readwise.io/read/01jv1p38pyq19t6ygqx3h642pn)) ^888634319
- After implementing the previous optimizations, we turned to profiling import times using Python’s `-X importtime` option. ([View Highlight](https://read.readwise.io/read/01jv1p40vte5ezj7270phgbe86)) ^888634356