September 2017
Intermediate to advanced
222 pages
5h 1m
English
In the last chapter, you got pytest up and running. You saw how to run it against files and directories and how many of the options worked. In this chapter, you’ll learn how to write test functions in the context of testing a Python package. If you’re using pytest to test something other than a Python package, most of this chapter still applies.
We’re going to write tests for the Tasks package. Before we do that, I’ll talk about the structure of a distributable Python package and the tests for it, and how to get the tests able to see the package under test. Then I’ll show you how to use assert in tests, how tests handle unexpected exceptions, and testing for expected exceptions.
Eventually, we’ll have a lot of ...
Read now
Unlock full access