pyATS Results

26.3 · active · verified Thu Apr 16

pyATS Results is a core component of the Cisco pyATS framework, providing an object-oriented API for representing and managing test execution results such as Pass, Fail, Warn, Error, and others. It ensures consistent handling and reporting across various test scenarios within the pyATS ecosystem. As of version 26.3, it is actively maintained with frequent releases aligned with the broader pyATS framework, typically on a monthly cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate and use `pyats.results` objects to represent different test outcomes. It shows creating specific result types like `Pass` and `Fail`, as well as using the base `Result` class to explicitly set a state like 'Blocked' or 'Warning'.

from pyats.results import Pass, Fail, Result

def run_my_test_example():
    # Example 1: Using specific result classes
    test_case_status = True
    if test_case_status:
        result1 = Pass('Scenario A completed successfully.')
    else:
        result1 = Fail('Scenario A encountered a critical error.')

    # Example 2: Using the base Result class and setting its state
    result2 = Result()
    result2.state = 'Blocked'
    result2.message = 'Scenario B was blocked by a previous failure.'

    # Example 3: Instantiating a warning
    result3 = Result()
    result3.state = 'Warning'
    result3.message = 'Scenario C completed with minor warnings.'

    print(f"Test 1: {result1.state} - {result1.message}")
    print(f"Test 2: {result2.state} - {result2.message}")
    print(f"Test 3: {result3.state} - {result3.message}")

    # Assertions for quickstart validation
    assert result1.state == 'Passed'
    assert result2.state == 'Blocked'
    assert result3.state == 'Warning'

if __name__ == "__main__":
    run_my_test_example()

view raw JSON →