pysys.constants¶
Standard constants that are used throughout the PySys framework.
The convention is to import all contents of the module so that the constants can be referenced directly.
HOSTNAME¶
- pysys.constants.HOSTNAME = 'ahv-win2019'¶
The fully qualified name of this host.
PLATFORM¶
- pysys.constants.PLATFORM = 'win32'¶
OS platform - current values are:
linux
,win32
(Windows),sunos
(Solaris),darwin
(Mac). It is recommended to use standard Python functions such assys.platform
rather than this constant.
PREFERRED_ENCODING¶
- pysys.constants.PREFERRED_ENCODING = 'cp1252'¶
The operating system’s preferred/default encoding for reading/writing the contents of text data in files and process stdout/stderr for the current environment (or machine).
This returns the same value as Python’s
locale.getpreferredencoding()
method, but as that method is not thread-safe, this constant must always be used in test cases to avoid race conditions when running tests in parallel.The OS preferred encoding should not be confused with Python’s ‘default’ encoding (
sys.getdefaultencoding()
) which is usually not relevant for testing purposes.See also
pysys.basetest.BaseTest.getDefaultFileEncoding()
.New in version 2.0.
IS_WINDOWS¶
- pysys.constants.IS_WINDOWS = True¶
True if this is Windows, False for other operating systems such as Unix.
PYTHON_EXE¶
- pysys.constants.PYTHON_EXE = 'c:\\apama_build\\br\\rel\\10.11.3.x\\apama-lib5\\win\\amd64\\all\\python\\3.9.5\\python.exe'¶
The path to the current Python executable (=``sys.executable``).
EXE_SUFFIX¶
- pysys.constants.EXE_SUFFIX = '.exe'¶
The suffix added to binary executables, that is
.exe
on Windows, and empty string on Unix.
BACKGROUND¶
- pysys.constants.BACKGROUND = 10¶
Constant indicating a process is to be started asynchronously in the background.
FOREGROUND¶
- pysys.constants.FOREGROUND = 11¶
Constant indicating a process is to be run synchronously in the foreground.
PASSED¶
INSPECT¶
NOTVERIFIED¶
FAILED¶
TIMEDOUT¶
BADPERF¶
- pysys.constants.BADPERF = BADPERF¶
Failure test
Outcome
indicating that the measured performance (speed, memory use, etc) was deemed insufficient. When using this outcome, it is always best to also report the underlying numeric values usingpysys.basetest.BaseTest.reportPerformanceResult
to provide a record of how close to the limit the performance has been historically. Note that until other failure outcomes, theBADPERF
outcome will not preventreportPerformanceResult
from recording subsequent results.
DUMPEDCORE¶
BLOCKED¶
SKIPPED¶
- pysys.constants.SKIPPED = SKIPPED(non-failure)¶
Non-failure test
Outcome
indicating that the test was ignored as it is not currently required to run on this platform/mode. Seepysys.basetest.BaseTest.skipTest
.
OUTCOMES¶
- pysys.constants.OUTCOMES = (SKIPPED(non-failure), BLOCKED, DUMPEDCORE, TIMEDOUT, FAILED, BADPERF, NOTVERIFIED(non-failure), INSPECT(non-failure), PASSED(non-failure))¶
Lists all possible test outcomes, in descending order of precedence.
Non-failure test
Outcome
indicating that the test was ignored as it is not currently required to run on this platform/mode.Failure test
Outcome
indicating that something went wrong, for example an exception was raised by the testcase or a required file could not be found.Failure test
Outcome
indicating that a crash occurred, and acore
file was generated (UNIX only).Failure test
Outcome
indicating that the test timed out while performing execution or validation operations.Failure test
Outcome
indicating validation steps with a negative outcome.Failure test
Outcome
indicating that the measured performance (speed, memory use, etc) was deemed insufficient.Non-failure test
Outcome
indicating that it was not possible to positively validate correct operation.Non-failure test
Outcome
indicating that manual inspection of the test output is required (in addition to any automated checks).Non-failure test
Outcome
indicating successful validation steps.If a test adds multiple outcomes, the outcome with highest precedence is used as the final test outcome (i.e. SKIPPED rather than FAILED, and FAILED rather than PASSED etc).
Each item is an instance of
Outcome
. UseOutcome.isFailure()
to check whether a given outcome is classed as a failure for reporting purposes.
PRECEDENT¶
FAILS¶
- pysys.constants.FAILS = [BLOCKED, DUMPEDCORE, TIMEDOUT, FAILED, BADPERF]¶
- Deprecated
To test whether a specific outcome from OUTCOMES is a failure, use
Outcome.isFailure()
.
LOOKUP¶
- pysys.constants.LOOKUP = {SKIPPED(non-failure): 'SKIPPED', BLOCKED: 'BLOCKED', DUMPEDCORE: 'DUMPED CORE', TIMEDOUT: 'TIMED OUT', FAILED: 'FAILED', BADPERF: 'BAD PERFORMANCE', NOTVERIFIED(non-failure): 'NOT VERIFIED', INSPECT(non-failure): 'REQUIRES INSPECTION', PASSED(non-failure): 'PASSED', True: 'TRUE', False: 'FALSE'}¶
Lookup dictionary providing the string representation of test outcomes. :deprecated: Use
str(outcome)
on theOutcome
to convert to the display name.
OSWALK_IGNORES¶
- pysys.constants.OSWALK_IGNORES = ['.git', '.svn', '__pycache__', 'CVS']¶
A list of directory names to exclude when recursively walking a directory tree.
This is used by PySys during test loading, and can also be used for subsequent directory walking operations.
DEFAULT_TIMEOUT¶
TIMEOUTS¶
- pysys.constants.TIMEOUTS = {'ManualTester': 1800, 'WaitForAvailableTCPPort': 300, 'WaitForFile': 30, 'WaitForProcess': 600, 'WaitForProcessStop': 30, 'WaitForSignal': 60, 'WaitForSocket': 60}¶
Default timeouts used for various operations.
Each timeout is given as a floating point number of seconds.
These timeouts can be customized from a runner plugin (or
pysys.baserunner.BaseRunner.setup()
) if needed (but never change them from within individual testcases).
Outcome¶
- class pysys.constants.Outcome(id, isFailure, displayName=None)[source]¶
Bases:
object
Represents a PySys test outcome that can be reported using
pysys.basetest.BaseTest.addOutcome()
.The possible outcomes are listed in
OUTCOMES
.Use
str()
or%s
to get the display name for an outcome (e.g. “TIMED OUT”), andisFailure()
to check if it’s a failure outcome.- isFailure()[source]¶
- Return bool
True if this outcome is classed as failure, or False if not (e.g.
SKIPPED
andNOTVERIFIED
are not failures).
PrintLogs¶
- class pysys.constants.PrintLogs(value)[source]¶
Bases:
enum.Enum
Enumeration constants that specify when run.log contents are printed to the stdout console.
In all cases a summary of failures is printed at the end, and the user can always look at the run.log inside each output directory if they need more detail.
- NONE = 'PrintLogs.NONE'¶
Detailed run.log output is not printed to the stdout console.
- ALL = 'PrintLogs.ALL'¶
Detailed run.log output is always printed to the stdout console, for both passed and failed testcases.
- FAILURES = 'PrintLogs.FAILURES'¶
Detailed run.log output is only printed to the stdout console for failed testcases.