The chapter started by emphasizing the need for testing. It introduced you to the unit testing framework in Python. You learned how to write and execute unit tests. The next topic served as an introduction to Python mock library. The chapter demonstrated the use of Mock
objects in unit tests. Next, it showed an example where it was difficult to write a unit test without refactoring the code first. At this point, you learned the basics of refactoring, refactored the code, and then developed a unit test for this example.
During development, you often encounter a recurring problem. Often, a general solution (or a recipe) exists that works for this problem. This is often referred to as a design pattern. In the next chapter, we will review a few commonly used design patterns in Python.