results

Functions and helpers for result management when working with

TMT uses the standard reporting behavior (result:respect), where the overall test outcome is determined by the exit code. Sub-results are reported as flat entries in tmt-report-results.yaml (the same file that the tmt-report-result script writes to), and TMT converts them into subresults under the main test result. Log files for the main result are submitted via the tmt-file-submit command, which copies them to the TMT data directory and registers them to be included in the main result’s log list. See: https://tmt.readthedocs.io/en/stable/spec/results.html https://tmt.readthedocs.io/en/stable/spec/tests.html#spec-tests-result

Module Contents

class results.Counter

Bases: collections.defaultdict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

total()
results.global_counts
results.have_atex_api()

Return True if we can report results via ATEX natively.

results.have_tmt_api()

Return True if we can report results via TMT natively.

results.report_atex(status, name=None, note=None, logs=None, *, partial=False)
results.report_tmt(status, name=None, note=None, logs=None)
results.report_plain(status, name=None, note=None, logs=None)
results.report(status, name=None, note=None, logs=None)

Report a test result.

‘name’ will be appended to the currently running test name, allowing the test to report one or more sub-results. If empty, result for the test itself is reported.

‘logs’ is a list of file paths (relative to CWD) to be copied or uploaded, and associated with the new result.

Returns the final ‘status’, potentially modified by the waiving logic.

results.atex_upload_log_data(name, data)

Append raw data to a named log file for the main test result.

Uses ATEX partial result file appending - specifying the same filename in multiple partial=True calls appends to the file. Outside ATEX, this is a no-op.

‘name’ can be a string or Path; only the basename is used. ‘data’ is appended as-is (bytes or str, encoded to UTF-8 if str). The caller is responsible for including any line terminators.

results.register_log(filepath)

Pre-register a log file and return the path to write it to.

For TMT: returns a path inside TMT_TEST_DATA and registers the name in TMT_TEST_SUBMITTED_FILES, so the file survives temporary directory cleanup and is available for collection even after a crash. For ATEX / plain: returns the original filepath (ATEX streaming provides its own crash-safety).

Call this before opening the log file, then open the returned path.

results.add_log(*logs)

Add log file(s) to be associated with the main test result.

The log file(s) will be processed immediately: - For ATEX: uploaded as a partial result, skipping files that were

already streamed via atex_upload_log_data() (to avoid duplicates)

  • For TMT: submitted via tmt-file-submit so they appear on the main result (no-op if the file was already pre-registered via register_log())

This allows logs to be added incrementally throughout the test, and ensures they’re available even if the test later fails with a traceback.

Multiple logs can be added by calling this function multiple times, or by passing multiple arguments.

results.report_and_exit(status=None, note=None, logs=None)

Report a result for the test itself and exit with 0 or 2, depending on whether there were any failures reported during execution of the test.

Additional logs can be passed via the ‘logs’ parameter.