6. Registering and Distributing Extension Classes

To use your Extension class, you must place the Python module file containing it in a directory where QMTest can find it. QMTest searches for extensions in particular places, in the following order:

  1. in the paths contained in the QMTEST_CLASS_PATH environment variable.

  2. in the class-path associated with a particular test database (typically the QMTest/ subdirectory).

  3. in the site-extension path associated with a particular QMTest installation.

  4. in the set of built-in extensions that come with a particular QMTest installation.

You should generally place module files containing extension classes in the test database's QMTest directory, unless you plan to use the test classes in more than one test database.

You must use the qmtest register command to register your new extension class. You must perform this step no matter where you place the module containing your extension class.

You can refer to the new extension class using the syntax module.Class, where module is the name of the module and Class is the name of the class.

To make your extension classes sharable by other test database instances, you should install them into the site-extension path associated with a qmtest installation.

To facilitate this installation, QMTest provides code that can be used in conjunction with python's distutils to install, and even distribute them. The following setup.py script will allow you to install (and even package !) all extension modules from the extensions subdirectory:

from qm.dist.distribution import Distribution
from distutils.core import setup

setup(distclass=Distribution,
      qmtest_extensions="extensions")
  

Then, the following command installs extension modules from extensions:

> python setup.py install