pysys.xml.descriptor module

class pysys.xml.descriptor.DescriptorLoader(project, **kwargs)[source]

Bases: object

This class is responsible for locating and loading all available testcase descriptors.

A custom DescriptorLoader subclass can be provided to provide more dynamic behaviour, typically by overriding loadDescriptors and modifying the returned list of descriptors.

You could use this approach to add additional descriptor instances to represent non-PySys testcases found under the search directory.

Another key use case would be dynamically adding or changing descriptor settings such as the list of modes for each testcase or the executionOrderHint, perhaps based on a per-group basis. For example, you could modify descriptors in the “database-tests” group to have a dynamically generated list of modes identifying the possible database servers supported without having to hardcode that list into any descriptor files on disk, and allowing for different database modes on different platforms.

Variables:project – The Project instance.
__init__(project, **kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

loadDescriptors(dir, **kwargs)[source]

Find all descriptors located under the specified directory, and return them as a list.

Subclasses may change the returned descriptors and/or add additional instances of their own to the list after calling the super implementation:

descriptors = super(CustomDescriptorLoader, self).loadDescriptors(dir, \*\*kwargs)
...
return descriptors
Parameters:dir – The parent directory to search for runnable tests.
Returns:List of pysys.xml.descriptor.TestDescriptor objects which could be selected for execution. If a test can be run in multiple modes there must be a single descriptor for it in the list returned from this method. Each multi-mode descriptor is later expanded out into separate mode-specific descriptors (at the same time as descriptor filtering based on command line arguments, and addition of project-level execution-order), before the final list is sorted and passed to pysys.baserunner.BaseRunner. The order of the returned list is random, so the caller is responsible for sorting this list to ensure deterministic behaviour.
Return type:list
Raises:UserError – Raised if no testcases can be found.
class pysys.xml.descriptor.TestDescriptor(file, id, type='auto', state='runnable', title='(no title)', purpose='', groups=[], modes=[], classname='PySysTest', module='run', input='Input', output='Output', reference='Reference', traceability=[], executionOrderHint=0.0, skippedReason=None, testDir=None, isDirConfig=False)[source]

Bases: object

Contains descriptor metadata about an individual testcase.

Also used for descriptors specifying defaults for a directory subtree containing a related set of testcases.

The DescriptorLoader class is responsible for determining the available descriptor instances.

Variables:
  • file – The absolute path of the testcase descriptor file.
  • testDir – The absolute path of the test, which is used to convert any relative paths into absolute paths.
  • id – The testcase identifier, or the id prefix if this is a directory config descriptor rather than a testcase descriptor. Includes a mode suffix if this is a multi-mode test and supportMultipleModesPerRun=True.
  • idWithoutMode – The raw testcase identifier with no mode suffix.
  • type – The type of the testcase (automated or manual)
  • state – The state of the testcase (runnable, deprecated or skipped)
  • skippedReason – If set to a non-empty string, indicates that this testcase is skipped and provides the reason. If this is set then the test is skipped regardless of the value of state.
  • title – The one-line title summarizing this testcase
  • purpose – A detailed description of the purpose of the testcase
  • groups – A list of the user defined groups the testcase belongs to
  • modes – A list of the user defined modes the testcase can be run in
  • primaryMode – Specifies the primary mode for this test id (which may be None if this test has no modes). Usually this is the first mode in the list.
  • mode – Specifies which of the possible modes this descriptor represents or None if the the descriptor has no modes. This field is only present after the raw descriptors have been expanded into multiple mode-specific descriptors, and only if supportMultipleModesPerRun=True.
  • classname – The Python classname to be executed for this testcase
  • module – The path to the python module containing the testcase class. Relative to testDir, or an absoute path.
  • input – The path to the input directory of the testcase. Relative to testDir, or an absoute path.
  • output – The path to the output parent directory of the testcase. Relative to testDir, or an absoute path.
  • reference – The path to the reference directory of the testcase. Relative to testDir, or an absoute path.
  • traceability – A list of the requirements covered by the testcase
  • executionOrderHint – A float priority value used to determine the order in which testcases will be run; higher values are executed before low values. The default is 0.0.
  • isDirConfig – True if this is a directory configuration, or False if it’s a normal testcase.
  • userData – A dictionary that can be used for storing user-defined data in the descriptor.
__init__(file, id, type='auto', state='runnable', title='(no title)', purpose='', groups=[], modes=[], classname='PySysTest', module='run', input='Input', output='Output', reference='Reference', traceability=[], executionOrderHint=0.0, skippedReason=None, testDir=None, isDirConfig=False)[source]

Create an instance of the class.

After construction the self.mode attribute is not set until later cloning and expansion of each container for the supported modes.

classname
executionOrderHint
executionOrderHintsByMode
file
groups
id
idWithoutMode
input
isDirConfig
mode
modes
module
output
primaryMode
purpose
reference
skippedReason
state
testDir
title
toDict()[source]

Converts this descriptor to an (ordered) dict suitable for serialization.

traceability
type
userData
pysys.xml.descriptor.XMLDescriptorContainer

XMLDescriptorContainer is an alias for the TestDescriptor class, which exists for compatibility reasons only.

alias of pysys.xml.descriptor.TestDescriptor