pyATS AEtest

26.3 · active · verified Thu Apr 16

pyATS AEtest (version 26.3) is the primary test automation engine within the Cisco pyATS framework, designed for structured and hierarchical test script development, particularly for network device testing. It provides robust features such as common setup/cleanup stages, testcase parametrization, and comprehensive result reporting. The library typically follows a monthly or bi-monthly release cadence, aligning with broader pyATS framework updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the basic structure of a pyATS AEtest script, including `CommonSetup`, `Testcase`, and `CommonCleanup` sections. It defines a simple testcase that uses data set up in the CommonSetup. The `aetest.main()` call allows the script to be executed directly.

from pyats import aetest

class CommonSetup(aetest.CommonSetup):
    """Common Setup for all testcases"""
    @aetest.subsection
    def initial_setup(self):
        self.parent.parameters['my_data'] = 'initialized_data'
        self.passed('Common Setup completed')

class TestcaseOne(aetest.Testcase):
    """A simple testcase"""
    @aetest.test
    def check_data(self):
        data = self.parent.parameters.get('my_data')
        if data == 'initialized_data':
            self.passed(f'Data matched: {data}')
        else:
            self.failed(f'Unexpected data: {data}')

class CommonCleanup(aetest.CommonCleanup):
    """Common Cleanup for all testcases"""
    @aetest.subsection
    def final_cleanup(self):
        self.passed('Common Cleanup completed')

if __name__ == '__main__':
    # To run this script:
    # 1. Save it as e.g., my_test.py
    # 2. Execute: python my_test.py
    # For advanced features like testbed parsing, use 'pyats run testbed my_test.py'
    aetest.main()

view raw JSON →