pysys.xml.project module

Contains the Project class which holds configuration for the entire test project.

class pysys.xml.project.Project(root, projectFile)[source]

Bases: object

Contains settings for the entire test project, as defined by the pysysproject.xml project configuration file.

To get a reference to the current Project instance, use the pysys.basetest.BaseTest.project (or pysys.process.user.ProcessUser.project) field.

This class reads and parses the PySys project file if it exists and sets an instance field for every:

<property name="...">value</property>

element in the file.

Variables:
  • root (string) – Full path to the project root directory, as specified by the first PySys project file encountered when walking up the directory tree from the start directory. If no project file was found, this is just the start directory PySys was run from.
  • projectFile (string) – Full path to the project file. May be None, though providing a file is recommended.
__init__(root, projectFile)[source]

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

static findAndLoadProject(startdir)[source]

Find and load a project file, starting from the specified directory.

If this fails an error is logged and the process is terminated.

The method walks up the directory tree from the supplied path until the PySys project file is found. The location of the project file defines the project root location. The contents of the project file determine project specific constants as specified by property elements in the xml project file.

To ensure that all loaded modules have a pre-initialised projects instance, any launching application should first import the loadproject file, and then make a call to it prior to importing all names within the constants module.

Parameters:startdir – The initial path to start from when trying to locate the project file
static getInstance()[source]

Provides access to the singleton instance of Project.

Raises an exception if the project has not yet been loaded.

Use self.project to get access to the project instance where possible, for example from a BaseTest or BaseRunner class. This attribute is for use in internal classes that do not have a self.project.

pysys.xml.project.createProjectConfig(targetdir, templatepath=None)[source]

Create a new project configuration file in the specified targetdir.

pysys.xml.project.getProjectConfigTemplates()[source]

Get a list of available templates that can be used for creating a new project configuration.

Returns:A dict, where each value is an absolute path to an XML template file and each key is the display name for that template.