Option Flags and Directives

Let's discuss option flags and their derivatives.

We'll cover the following

The doctest module comes with several option flags that we can use to control doctest's behavior. There are quite a few of them, so we will only look at a couple of examples of one flag to show how we might use them.

One of the easiest ways to use an option flag is with a directive. A doctest directive is a special Python comment that follows an example’s source code. One of the most popular option flags to use is the ELLIPSIS flag. Let’s put the following code into a file and name it test_directives.py:

Get hands-on with 1200+ tech skills courses.