What are the top downloaded pytest plugins?
I want to know this. And I’d like the answer updated regularly.
So today I decided to write a script to do that for me.

Grab data

Let’s start with Top PyPI Packages from Hugo van Kemenade. This list is “A monthly dump of the 8,000 most-downloaded packages from PyPI.”

Perfect.

Parse

Now:

  • Filter for “pytest” in the package name
  • Remove “pytest” itself.
    • I could leave this in for comparison, but it would always be #1.
  • Renumber.
  • Include a link to the pypi.org package page.
  • Throw it all in a table.
  • Pipe it to a markdown blog page.

Added on 26-Aug:

Grab summaries from pypi.org via Warehouse API.
Thanks Jeff Triplett and Hugo for pointing me in that direction.

Final Results

And the result is Top pytest plugins

The top 10

As of July 1, 2024 data

Package Downloads Description
1 pytest-cov 47,584,744 Pytest plugin for measuring coverage, using coverage.py
2 pytest-runner 30,486,401 Deprecated plugin adds setup.py test support for pytest runner
3 pytest-xdist 18,363,303 parallel and distributed testing
4 pytest-mock 14,217,126 Thin-wrapper around the mock package
5 pytest-metadata 11,007,394 test session metadata
6 pytest-html 9,107,640 generating HTML reports
7 pytest-asyncio 8,906,276 support for asyncio
8 pytest-timeout 6,196,754 abort hanging tests
9 pytest-rerunfailures 5,766,300 re-run tests
10 pytest-split 4,296,398 splits the test suite to equally sized sub suites based on test execution time.

Is pytest-check still in the list?

Yep. My little pytest-check is sitting at #25. Nice.

Package Downloads Description
25 pytest-check 1,332,316 allows multiple failures per test

Does this make sense?

pytest-cov at the top. Sure. Using coverage.py through this plugin is pretty common.

But pytest-runner? This is a deprecated plugin. I’m so used to pyproject.toml based projects that I forget there are a ton of setup.py projects still out there.

I think pytest-xdist totally makes sense. For large suites that can run in parallel, why not?

A couple years ago, I could totally see why pytest-mock is so popular, as it was the most conveninet way to wrap your mock in a context manager. However, now unittest.mock includes the with patch syntax, which I frequently find more convenient than pulling in another plugin. But pytest-mock still works great, and there’s probably a lot of code out there written before the with patch model was in common use.

Then -html, and -metadata for reporting, -asyncio for the rise in async. -timeout to avoid hanging tests, great for CI use. -rerunfailures is quite useful for any slightly flaky test, as you know you’re going to re-run it anyway, may as well just have it re-run automatically.

The cool new item, for me, on the list is pytest-split. I’ve forgotten about this, and really want to try it out. Seems like you run your suite once and save the times into a file you check in. Then use that to split into separate runs. For old school Jenkins CI, you could manually set up a handful of jobs to run the suite in parallel.

There’s a lot of other gems in the list, so check out the full list at Top pytest plugins

Keeping it updated.

I’m running a script to generate this, locally right now.
I do plan on setting this up to run regularly.

Descriptions

The list at Top pytest plugins doesn’t currently have descriptions, as the Top PyPI Packages data set doesn’t include descriptions.
I think it’d be cool to include them though. So, I may do a bit of research to figure out a way to grab them.

Source code

The code is nothing fancy, but if you’re curious, its at github.com/okken/top-pytest-plugins

Addendum 26-Aug

Thanks Jeff Triplett and Hugo van Kemenade for pointing me to to the pypi.org Warehouse API to allow me to add summaries.