Chapter Twelve · Growing Up

Tests, Tools and What Comes Next

The last chapter turns checking by hand into checking automatically, reads one complete program from top to bottom, names the tools professionals add around the language, and maps where to go from here.

Every program in this book so far was checked the same way: run it, look at the output, decide whether it was right. That works for ten lines. It stops working when a program is long enough that a change in one place can quietly break something in another. This chapter starts with the fix, automated tests, and then steps back to look at everything you can now do.

Five topics. A test as a promise you can run, with nothing but assert. pytest, the tool almost every Python project uses to run its tests. One complete program of about a hundred and fifty lines, read end to end, where every line is something an earlier page taught. The tools of the trade: editors, formatters, linters and assistants, the one page in this chapter that names products. And the next steps, in this catalogue and beyond.

How tests change the way you work
Write the functionparameters in, return out
→
Write the testspromises you can run
→
Run thempython -m pytest
→
Change with confidenceand go again

Topics in This Chapter