Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Module support in doctests

Project Description

A plugin to enable the definition and usage of whole Python modules from within doctests.

Intro and Motivation

manuelpi.fakemodule is a plugin for Manuel that supports syntax for creating modules within a doctest. The module, once defined, is then usable by subsequent doctest statements.

This functionality is useful for packages that you might describe as being ‘meta’; they operate on modules. Thus, being able to define and then process modules within the same doctest using a clean and uncluttered syntax is extremely beneficial.

One such package to benefit from this sort of facility is Martian, which scans modules for configuration directives, registering them as it goes.


The special REStructure Text directive:

'.. module-block:: <MODULE_NAME>'

is used to denote the start of a module and its alias <MODULE_NAME> for the rest of the doctest. We then define the module’s body at a single indentation level after this directive. What follows is an example of a full doctest:

We create a new module with a main function to perform this task::

.. module-block:: test_module

   import sys

   class A:
       def do_something(self):
           return "Hello World"

   def main():
       print A().do_something()

 Now let's execute the main function
>>> test_module.main()
Hello World

The above doctest creates a new module test_module and then exercises the objects within it. Notice how the module becomes immediately available to the doctet after its definition.

To use manualpi.fakemodule in your application, set up your tests as described in the Manuel documentation and import the Manuel class from manuelpi.fakemodule:

import manuelpi.fakemodule
m += manuelpi.fakemodule.Manuel()


0.1b1 (2009-12-16)

  • Initial Public Release
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
manuelpi.fakemodule-0.1b1.tar.gz (7.2 kB) Copy SHA256 Checksum SHA256 Source Dec 16, 2009

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting