April 2015
Intermediate to advanced
264 pages
5h 31m
English
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 ...Read now
Unlock full access