I’ve been babbling on about testing for a decade now. Here’s a quick list of pytest plugins I use in most of my Python projects:
- pytest-cov – pytest integration for the wonderful coverage tool by Ned Batchelder.
- pytest-mock – pytest integration for the unittest.mock library.
- pytest-instafail – Print out the test failure as it happens, instead of waiting for all tests to finish. I’ve only recently discovered this one, and I’m breaking into cold sweat thinking how much time I’ve wasted in the past decade waiting for the test suite to finish just to see the output of that one failing test.
- pytest-randomly – Catch flaky tests by running your tests in a random order. Additionally, you can pass in the
—randomly-seedvalue to repeat a randomness-induced failure. Hate flaky tests? Check out BuildPulse.io to get help finding and fixing them.
- pytest-socket – I like my tests fast. A surefire way to make tests slow is to have them connect to the Internet. This plugin prevents any test from doing (unmocked) network calls and as such ensures a faster test suite.
- pytest-csv – A dependency of BlueRacer.io, so that I can keep an eye on the speed of my test suite.
- pytest-splinter – Real-browser testing of web apps with splinter. Unit tests are not enough. I always have a few real-browser tests to verify that all parts of my stack are correctly glued together.
That’s it, short and sweet. Happy testing!