All extensions to QMTest are implemented by writing a new Python class. This new Python class will be derived from an appropriate existing QMTest Python class. For example, new test classes are derived from Test while new test database classes are derived from Database.
The classes from which new extensions are derived (like Test) are all themselves derived from Extension. The Extension class provides the basic framework used by all extension classes. In particular, every instance of Extension can be represented in XML format in persistent storage.
Every Extension class has an associated list of arguments. When an Extension instance is written out as XML, the value of each argument which is encoded in the output. Similarly, when an Extension instance is read back in, the arguments are decoded. Conceptually, two Extension instances are the same if they are instances of the same derived class and their arguments have the same values.
Each argument has both a name and a type. For example, every Test has an argument called target_group. The target group is a string indicating on which targets a particular test should be run.
Each argument is represented by an instance of Field. A Field instance can read or write values in XML format. A Field can also produce an HTML representation of a value, or an HTML form that allows a user to update the value of the field. It is the fact that all Extension arguments are instances of Field that makes it possible to represent Extension instances as XML. Smilarly, it is the the use of the Field class that allows the user to edit tests in the QMTest GUI.
Each class derived from Extension may contain a variable called arguments. The value of arguments must be a list of Field instances. The complete set of arguments for a derived class consists of the arguments specified in the derived class together with all of those specified in base classes. In other words, a derived class should not explicitly include arguments that have already been specified in a base class.
For example, after the following class definitions:
class A(Extension): arguments = [ TextField("x") ] class B(A): arguments = [ IntegerField("y"), TextField("z") ]A has one argument (x) and B has three arguments (x, y, and z).
None of the arguments may have the same name as a class variable in the extension class, including class variables in base classes.