Chapter 4. Getting organized
Until now, you’ve been learning how to use Python, and programming has been “by the seat of your pants.” Hunt the Wumpus didn’t have much in the way of planning and no tests at all, and, although you tested in the last chapter, you did so only fairly lightly. Now, you’ll change tactics and focus on how to plan and test programs more thoroughly. You’ll also do some more tricky things with functions and learn about pickle and text-wrap, two more of Python’s standard libraries.
The major change in this chapter is that you’ll start learning how to test programs automatically. Unit tests are a relatively recent idea and help offload a lot of the grunt work of testing and debugging your programs onto the computer. You’ll also be turning development practice on its head by using Test-Driven Development, writing tests before the program. It sounds odd, but it can be enlightening to see how unit testing can make tricky problems easy, and how writing tests first can help shape the design of your program for the better.