Website hosting service by

 Back to Index

5.2.3 What's the Execution Context?

By default, each time testmod() finds a docstring to test, it uses a copy of M's globals, so that running tests on a module doesn't change the module's real globals, and so that one test in M can't leave behind crumbs that accidentally allow another test to work. This means examples can freely use any names defined at top-level in M, and names defined earlier in the docstring being run.

You can force use of your own dict as the execution context by passing globs=your_dict to testmod() instead. Presumably this would be a copy of M.__dict__ merged with the globals from other imported modules.




2002-2004 Webhosting Service


Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to


Domain registration : Buy domain name or register domain name from $5.95/year only


Cheap domain registration : Register domain name or buy domain name, including free domain hosting services offers cheap domain registration, domain name transfer and domain search services