How It Works

This example runs a module as a Python program. Using the idiom to detect this situation, the module merely runs the test function. The output you see is the output of the tests.

Note how the output runs an instance of each class defined in the module, as well as tests the raising of the AngryChefException.

If you follow all of the guidelines in this section, your modules will meet the expectations of other Python developers. Moreover, your modules will work better in your scripts. You can see all of this in action in the next section, which shows a complete Python module.

Was this article helpful?

0 0