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

Class Target
source code

         object --+    
                  |    
extension.Extension --+
                      |
                     Target
Known Subclasses:
classes.thread_target.ThreadTarget, classes.serial_target.SerialTarget, classes.process_target.ProcessTarget

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

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

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


Class Variables [hide private]
_argument_dictionary A map from argument names to 'Field' instances.
_argument_list A list of all the 'Field's in this class.
arguments A list of the arguments to the extension class.
group  
kind A string giving kind of extension is implemented by the class.
name  

Inherited from object: __class__


Method Details [hide private]

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.

GetGroup(self)

source code 

Return the group of which the target is a member.

Derived classes must not override this method.

GetName(self)

source code 

Return the name of the target.

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.

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.

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.

_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'.

_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.

_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.

_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'.

_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.

_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.

__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.

__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: extension.Extension.__init__

Class Variable Details [hide private]

_argument_dictionary

A map from argument names to 'Field' instances.

A map from the names of arguments for this class to the corresponding 'Field'.
Value:
{'group': <<class 'qm.fields.TextField'> group>,
 'name': <<class 'qm.fields.TextField'> name>}                         
      

_argument_list

A list of all the 'Field's in this class.

This list combines the complete list of 'arguments'. 'Field's appear in the order reached by a pre-order breadth-first traversal of the hierarchy, starting from the most derived class.
Value:
[<<class 'qm.fields.TextField'> group>, <<class 'qm.fields.TextField'>\
 name>]                                                                
      

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:
[<<class 'qm.fields.TextField'> name>, <<class 'qm.fields.TextField'> \
group>]                                                                
      

group

Value:
''                                                                     
      

kind

A string giving kind of extension is implemented by the class.

This field is used in an application-specific way; for example, QMTest has 'test' and 'target' extension classes.
Value:
'target'                                                               
      

name

Value:
''