Writing Your Own Plugins

Many third-party plugins contain quite a bit of code. That’s one of the reasons we use them—to save us the time to develop all of that code ourselves. However, for your specific coding domain, you’ll undoubtedly come up with special fixtures and modifications that help you test. Even a handful of fixtures that you want to share between a couple of projects can be shared easily by creating a plugin. You can share those changes with multiple projects—and possibly the rest of the world—by developing and distributing your own plugins. It’s pretty easy to do so. In this section, we’ll develop a small modification to pytest behavior, package it as a plugin, test it, and look into how to distribute it.

Plugins can include ...

Get Python Testing with pytest now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.