A while ago, I came back to a Python project after other people had taken over maintenance. To my horror, the test suite was more than twice as slow as when I left it. And not because the codebase grew so much. Tests just got slower, bit by bit, and over time, the slowdowns accumulated.
I checked a couple of things I always do to make tests faster and managed to increase the speed by a good factor. At this point, I realized I wouldn’t have to do these optimizations if my list of common test slowness pitfalls was not buried inside my brain, but out there for everyone to use.
So here it is, a checklist to make your Python test suite faster: github.com/zupo/awesome-pytest-speedup
Some items are quick fixes and some are a bit more involved. If you prefer a video format, I’ve given a talk where I go through the list. Finally, if podcasts are your thing, Brian and Michael talked about it during their recent PythonBytes episode.