Summary
This chapter showed us how to write doctests
, make use of the shortcuts provided by py.test
, and use the logging
module. With testing, there is never a one-size-fits-all solution. While the doctest
system is very useful in many cases for providing both documentation and tests at the same time, in many functions, there are edge cases that simply don't matter for documentation, but still need to be tested. This is where regular unit tests come in and where py.test
helps a lot.
Because the py.test
library is always evolving, this chapter cannot fully cover everything you will need, but it should provide you with enough of a basis to be able to use it effectively and extend it where needed.
The logging module is extremely useful but it's also a pain if configured incorrectly. Unfortunately, the right configuration can be a bit obscure when multiple modules are trying to configure logging simultaneously. The usage of the logging system should be clear enough for most of the common use cases...