23.2.6.3 DocTestFinder objects

###
23.2.6.3 DocTestFinder objects

class `DocTestFinder`( | [verbose][, parser][, recurse][, exclude_empty])

  A processing class used to extract the `DocTest`s that are relevant to a given object, from its docstring and the docstrings of its contained objects. `DocTest`s can currently be extracted from the following object types: modules, functions, classes, methods, staticmethods, classmethods, and properties.

  The optional argument verbose can be used to display the objects searched by the finder. It defaults to `False` (no output).

  The optional argument parser specifies the `DocTestParser` object (or a drop-in replacement) that is used to extract doctests from docstrings.

  If the optional argument recurse is false, then `DocTestFinder.find()` will only examine the given object, and not any contained objects.

  If the optional argument exclude_empty is false, then `DocTestFinder.find()` will include tests for objects with empty docstrings.

  New in version 2.4.

`DocTestFinder` defines the following method:

`find`( | obj[, name][, module][, globs][, extraglobs])

  Return a list of the `DocTest`s that are defined by obj's docstring, or by any of its contained objects' docstrings.

  The optional argument name specifies the object's name; this name will be used to construct names for the returned `DocTest`s. If name is not specified, then `obj.__name__` is used.

  The optional parameter module is the module that contains the given object. If the module is not specified or is None, then the test finder will attempt to automatically determine the correct module. The object's module is used:

  - As a default namespace, if globs is not specified.
  - To prevent the DocTestFinder from extracting DocTests from objects that are imported from other modules. (Contained objects with modules other than module are ignored.)
  - To find the name of the file containing the object.
  - To help find the line number of the object within its file.

  If module is `False`, no attempt to find the module will be made. This is obscure, of use mostly in testing doctest itself: if module is `False`, or is `None` but cannot be found automatically, then all objects are considered to belong to the (non-existent) module, so all contained objects will (recursively) be searched for doctests.

  The globals for each `DocTest` is formed by combining globs and extraglobs (bindings in extraglobs override bindings in globs). A new shallow copy of the globals dictionary is created for each `DocTest`. If globs is not specified, then it defaults to the module's __dict__, if specified, or `{}` otherwise. If extraglobs is not specified, then it defaults to `{}`.