As we have seen so far, doctests can be written for methods, classes, and modules. However, they can also be written for whole packages. Typically, these would be put in the __init__.py
file of the package and would show how the package as a whole should work, including multiple interacting classes. Here is one such set of doctests from our __init__.py
file:
r""" The stock_alerter module allows you to set up rules and get alerted when those rules are met. >>> from datetime import datetime First, we need to setup an exchange that contains all the stocks that are going to be processed. A simple dictionary will do. >>> from stock_alerter.stock import Stock >>> exchange = {"GOOG": Stock("GOOG"), "AAPL": Stock("AAPL")} Next, we configure the reader. The reader is the source from where the stock updates are coming. The module provides two readers out of the box: A FileReader for reading updates from a comma separated file, and a ListReader to...