As powerful as pytest is, it can do even more when we add plugins. The pytest codebase is designed to allow customisation and extensions, and there are hooks that allow changes and improvements through plugins.

You may be surprised to find that you have already written some plugins if you have worked through the previous sections. Every time you add fixtures or hook functions to a project’s file, you are creating a local plugin. It’s just a little extra work to turn these files into installable plugins that you can share between projects, with other people, or with the world.

But first, let’s start with where you can find third-party plugins. There are quite a few plugins out there, so there’s a good chance that any changes you want to make to pytest have already been written.

Finding plugins

You can find third-party pytest plugins in various places, for example the pytest documentation contains an alphabetical list of plugins from You can also search itself, for pytest or for the pytest framework. Finally, many popular pytest plugins can also be found in pytest-dev on GitHub.

Installing plugins

Like other Python packages, pytest plugins can be easily installed with pip: python -m pip install pytest-cov.

Plugins for …

… modified test sequences

pytest usually executes our tests in a predictable order. For a directory of test files, pytest executes each file in alphabetical order. Within each file, each test is executed in the order in which it appears in the file. However, it can sometimes be useful to change this order. The following plugins change the usual sequence of a test:


executes tests in parallel, either with several CPUs on one machine or several remote machines.


re-executes failed tests and is particularly helpful in the case of faulty tests.


makes it easy to repeat one or more tests.


enables the order to be defined using Markers.


runs the tests in random order, first by file, then by class, then by test file.

… modified output

The normal pytest output mainly shows dots for passed tests and characters for other output. If you pass -v, you will see a list of test names with the result. However, there are plugins that change the output even further:


adds a --instafail option that reports tracebacks and output from failed tests immediately after the failure. Normally, pytest reports tracebacks and output from failed tests only after all tests have completed.


shows green checkmarks instead of dots for passed tests and has a nice progress bar. Like pytest-instafail, it also shows failures immediately.


enables the creation of HTML reports. Reports can be extended with additional data and images, such as screenshots of error cases.


improves diffs in the error messages of the pytest assertion with ICDiff.

… web development

pytest is used extensively for testing web projects and there is a long list of plugins that further simplify testing:


provides fixtures that enable simple configuration of browser-based tests with Selenium.


provide the high-level API of the Selenium-based Splinter to be used more easily from pytest.


facilitates the testing of HTTPX and FastAPI applications.

… fake data

We have already used Faker in Combining markers with fixtures to create multiple item instances. There are many cases in different areas where it is helpful to generate fake data. It is therefore not surprising that there are several plugins that fulfil this need:


generates fake data for you and offers a faker fixture for use with pytest.


contains fixtures for factory-boy, a database model data generator.


generates fake data similar to Faker, but Mimesis is a lot faster.

… various things


executes the Coverage during testing.


performs benchmark timing for code within tests.


prevents tests from running too long.


tests asynchronous functions.


is a thin wrapper around the unittest.mock patching API.


freezes the time so that any code that reads the time, date or clock time will get the same value during a test. set a specific time.


is a Pytest plugin for gRPC.


writes BDD tests with pytest.

Own plugins

See also