I assume that all of you write tests for Python programs with pytest. If you do not use pytest or if you do not even write tests, you should check out the following links which are useful and provide some examples and an overview of pytest's capabilities.
- Effective Python Testing With Pytest - Real Python
- Customizing your pytest suite (Part 1) - Raphael Pierzina
- Customizing your pytest suite (Part 2) - Raphael Pierzina
Maybe you should also have heard about test driven development (TDD), but I have little experience with it myself. If you have a great resource for beginners, send it my way and I can include it here.
What I did not find in these guides is a combination of patterns I use fairly often to write tests. Hopefully, it is useful for you as well. Let's go!
First, here is the function we are going to …