pysys.xml.project¶
The Project
class holds the pysysproject.xml
project configuration, including all
user-defined project properties.
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 thepysys.basetest.BaseTest.project
(orpysys.process.user.ProcessUser.project
) field.This class reads and parses the PySys project file if it exists and sets an instance attribute for every:
<property name="PROP_NAME">prop value</property>
element in the file.
- Variables
properties (dict(str,str)) – The resolved values of all project properties defined in the configuration file. In addition, each of these is set as an attribute onto the
Project
instance itself.root (str) – 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 (str) – Full path to the project file.
-
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 apysys.basetest.BaseTest
orpysys.baserunner.BaseRunner
class. This attribute is for use in internal functions and classes that do not have aself.project
.