Package qm :: Package test :: Module target :: Class Target
[hide private]
[frames] | no frames]

Class Target

source code

         object --+    
                  |    
extension.Extension --+
                      |
                     Target

Base class for target implementations.

A 'Target' is an entity that can run tests. QMTest can spread the workload from multiple tests across multiple targets. In addition, a single target can run more than one test at once.

'Target' is an abstract class.

You can extend QMTest by providing your own target class implementation.

To create your own target class, you must create a Python class derived (directly or indirectly) from 'Target'. The documentation for each method of 'Target' indicates whether you must override it in your target class implementation. Some methods may be overridden, but do not need to be. You might want to override such a method to provide a more efficient implementation, but QMTest will work fine if you just use the default version.

Nested Classes [hide private]
  __ResourceSetUpException
An exception indicating that a resource could not be set up.

Inherited from extension.Extension: Type, __metaclass__

Instance Methods [hide private]
 
__init__(self, database, arguments=None, **args)
Construct a 'Target'.
source code
 
GetName(self)
Return the name of the target.
source code
 
GetGroup(self)
Return the group of which the target is a member.
source code
 
GetDatabase(self)
Return the 'Database' containing the tests this target will run.
source code
 
IsIdle(self)
Return true if the target is idle.
source code
 
IsInGroup(self, group_pattern)
Returns true if this 'Target' is in a particular group.
source code
 
Start(self, response_queue, engine=None)
Start the target.
source code
 
Stop(self)
Stop the target.
source code
 
RunTest(self, descriptor, context)
Run the test given by 'test_id'.
source code
 
_RecordResult(self, result)
Record the 'result'.
source code
 
_BeginResourceSetUp(self, resource_name)
Begin setting up the indicated resource.
source code
 
_FinishResourceSetUp(self, resource, result, properties)
Finish setting up a resource.
source code
 
__SetUpResources(self, descriptor, context)
Set up all the resources associated with 'descriptor'.
source code
 
_SetUpResource(self, resource_name, context)
Set up the resource given by 'resource_id'.
source code
 
_CleanUpResource(self, name, resource)
Clean up the 'resource'.
source code
 
_GetTemporaryDirectory(self)
Return the path to a temporary directory.
source code

Inherited from extension.Extension: GetClassName, GetExplicitArguments, MakeDomDocument, MakeDomElement, Write, __getattr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  arguments = [qm.fields.TextField(name= "name", title= "Name", ...
A list of the arguments to the extension class.
  kind = "target"
A string giving kind of extension is implemented by the class.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, database, arguments=None, **args)
(Constructor)

source code 

Construct a 'Target'.

'database' -- The 'Database' containing the tests that will be run.

'arguments' -- As for 'Extension.__init__'.

'args' -- As for 'Extension.__init__'.

Overrides: object.__init__

GetName(self)

source code 

Return the name of the target.

Derived classes must not override this method.

GetGroup(self)

source code 

Return the group of which the target is a member.

Derived classes must not override this method.

GetDatabase(self)

source code 

Return the 'Database' containing the tests this target will run.

returns -- The 'Database' containing the tests this target will run.

Derived classes must not override this method.

IsIdle(self)

source code 

Return true if the target is idle.

returns -- True if the target is idle. If the target is idle, additional tasks may be assigned to it.

Derived classes must override this method.

IsInGroup(self, group_pattern)

source code 

Returns true if this 'Target' is in a particular group.

'group_pattern' -- A string giving a regular expression.

returns -- Returns true if the 'group_pattern' denotes a regular expression that matches the group for this 'Target', false otherwise.

Start(self, response_queue, engine=None)

source code 

Start the target.

'response_queue' -- The 'Queue' in which the results of test executions are placed.

'engine' -- The 'ExecutionEngine' that is starting the target, or 'None' if this target is being started without an 'ExecutionEngine'.

Derived classes may override this method, but the overriding method must call this method at some point during its execution.

Stop(self)

source code 

Stop the target.

Clean up all resources that have been set up on this target and take whatever other actions are required to stop the target.

Derived classes may override this method.

RunTest(self, descriptor, context)

source code 

Run the test given by 'test_id'.

'descriptor' -- The 'TestDescriptor' for the test.

'context' -- The 'Context' in which to run the test.

Derived classes may override this method.

_RecordResult(self, result)

source code 

Record the 'result'.

'result' -- A 'Result' of a test or resource execution.

Derived classes may override this method, but the overriding method must call this method at some point during its execution.

_BeginResourceSetUp(self, resource_name)

source code 

Begin setting up the indicated resource.

'resource_name' -- A string naming a resource.

returns -- If at attempt to set up the resource has already been made, returns a tuple '(resource, outcome, properties)'. The 'resource' is the 'Resource' object itself, but may be 'None' if the resource could not be set up. The 'outcome' indicates the outcome that resulted when the resource was set up. The 'properties' are a map from strings to strings indicating properties added by this resource.

If the resource has not been set up, but _BeginResourceSetUp has already been called for the resource, then the contents of the tuple will all be 'None'.

If this is the first time _BeginResourceSetUp has been called for this resource, then 'None' is returned, but the resource is marked as in the process of being set up. It is the caller's responsibility to finish setting it up by calling '_FinishResourceSetUp'.

_FinishResourceSetUp(self, resource, result, properties)

source code 

Finish setting up a resource.

'resource' -- The 'Resource' itself.

'result' -- The 'Result' associated with setting up the resource.

'properties' -- A dictionary of additional context properties that should be provided to tests that depend on this resource.

returns -- A tuple of the same form as is returned by '_BeginResourceSetUp' when the resource has already been set up.

__SetUpResources(self, descriptor, context)

source code 

Set up all the resources associated with 'descriptor'.

'descriptor' -- The 'TestDescriptor' or 'ResourceDescriptor' indicating the test or resource that is about to be run.

'context' -- The 'Context' in which the resources will be executed.

returns -- A tuple of the same form as is returned by '_BeginResourceSetUp' when the resource has already been set up.

_SetUpResource(self, resource_name, context)

source code 

Set up the resource given by 'resource_id'.

'resource_name' -- The name of the resource to be set up.

'context' -- The 'Context' in which to run the resource.

returns -- A map from strings to strings indicating additional properties added by this resource.

_CleanUpResource(self, name, resource)

source code 

Clean up the 'resource'.

'resource' -- The 'Resource' that should be cleaned up.

'name' -- The name of the resource itself.

_GetTemporaryDirectory(self)

source code 

Return the path to a temporary directory.

returns -- The path to a temporary directory to pass along to tests and resources via the 'TMPDIR_CONTEXT_PROPERTY'.


Class Variable Details [hide private]

arguments

A list of the arguments to the extension class.

Each element of this list should be an instance of 'Field'. The 'Field' instance describes the argument.

Derived classes may redefine this class variable. However, derived classes should not explicitly include the arguments from base classes; QMTest will automatically combine all the arguments found throughout the class hierarchy.

Value:
[qm.fields.TextField(name= "name", title= "Name", description= """The \
name of this target.

            The name of the target.  The target name will be recorded
            in any tests executed on that target so that you can see
            where the test was run.""", default_value= ""), qm.fields.\
TextField(name= "group", title= "Group", description= """The group ass\
ociated with this target.
...