When we build programs of even minor complexity, there are countless ways for defects to creep into our code. This can happen when we initially write the code, but we're just as likely to introduce defects when we make modifications to it. To help get a handle on defects and keep our code quality high, it's often very useful to have a set of tests that you can run that will tell if you if the code is acting as you expect.
To help make such tests, the Python standard library includes the unittest module. Despite
what its name suggests, this module helps with more than just unit testing. It is, in fact, a flexible framework for automating tests of all sorts, from acceptance tests to integration tests to unit tests. Its key feature, like many testing frameworks in many languages, is that it helps you make automated and...