pysys.writer.console

Writers that record test outcomes on the console (stdout) when running PySys.

If no progress writers are explicitly configured in the PySys project XML file, an instance of ConsoleProgressResultsWriter is used. If no summary writer is explicitly configured in the PySys project XML file, an instance of ConsoleSummaryResultsWriter is used.

ConsoleSummaryResultsWriter

class pysys.writer.console.ConsoleSummaryResultsWriter(logfile=None, **kwargs)[source]

Bases: pysys.writer.api.BaseSummaryResultsWriter, pysys.writer.api.TestOutcomeSummaryGenerator

Default summary writer that is used to list a summary of the test results at the end of execution.

Support the same configuration options as pysys.writer.api.TestOutcomeSummaryGenerator.

ConsoleProgressResultsWriter

class pysys.writer.console.ConsoleProgressResultsWriter(**kwargs)[source]

Bases: pysys.writer.api.BaseProgressResultsWriter

Default progress writer that logs a summary of progress so far to the console, after each test completes.

ConsoleFailureAnnotationsWriter

class pysys.writer.console.ConsoleFailureAnnotationsWriter(logfile=None, **kwargs)[source]

Bases: pysys.writer.api.BaseRecordResultsWriter

Writer that prints a single annotation line to stdout for each test failure, for IDEs and CI providers that can highlight failures found by regular expression stdout parsing.

An instance of this writer is automatically added to every project, and enables itself only if the PYSYS_CONSOLE_FAILURE_ANNOTATIONS environment variable is set.

This class is designed for simple cases. If you need to output in a format that requires escaping of special characters it is best to create a custom writer class.

format = ''

The format that will be written to stdout. If not specified as a writer property in pysysproject.xml, the environment variable PYSYS_CONSOLE_FAILURE_ANNOTATIONS will be used as the format.

The format can include the following placeholders:

  • @testFile@: the absolute path to the test file (e.g. run.py), using platform-specific slashes.

  • @testFile/@: the absolute path to the test file, using forward slashes on all OSes.

  • @testFileLine@: the line number in the test file (if available, else 0).

  • @runLogFile@: the absolute path to the run log (e.g. run.log), using platform-specific slashes.

  • @runLogFile/@: the absolute path to the run log (e.g. run.log), using forward slashes on all OSes.

  • @category@: either error or if it’s a non-failure outcome, warning.

  • @outcome@: the outcome e.g. FAILED.

  • @outcomeReason@: the string containing the reason for the failure; this string can contain any characters (other than newline).

  • @testIdAndCycle@: the test identifier, with a cycle suffix if this is a multi-cycle test.

The default format if the environment variable is empty and format is not provided is DEFAULT_FORMAT.

DEFAULT_FORMAT = '@testFile@:@testFileLine@: @category@: @outcome@ - @outcomeReason@ (@testIdAndCycle@)'

This is the default format if the environment variable is empty and format is not provided.

The output looks like this:

c:\myproject\tests\MyTest_001\run.py:4: error: TIMED OUT - This test timed out (MyTest_001 [CYCLE 03])

which is similar to output from “make” and so should be parseable by many tools and IDEs.

includeNonFailureOutcomes = 'NOT VERIFIED'

In addition to failure outcomes, any outcomes listed here (as comma-separated display names) will be reported (with a @category@ of warning rather than error).

enableIfEnvironmentVariable = 'PYSYS_CONSOLE_FAILURE_ANNOTATIONS'

The environment variable used to control whether it is enabled.

This writer will be enabled if the specified environment variable is set (either to any empty string or to any value other than “false”).

Set enableIfEnvironmentVariable to “” to ignore the environment and instead enable when running with --record.