pyATS Easypy
pyATS Easypy is the launcher and runtime environment for executing pyATS test scripts and harnesses. It provides jobfile parsing, plugin management, and the overall execution framework for network test automation. Part of the broader pyATS ecosystem from Cisco, it is actively maintained with frequent releases, currently at version 26.3, often following a monthly or bi-monthly cadence aligning with other pyATS components.
Common errors
-
ModuleNotFoundError: No module named 'pyats'
cause pyATS core package is not installed.fixRun `pip install pyats` or `pip install pyats.aetest` (if only the test framework is needed, though `pyats-easypy` might pull in core `pyats` anyway). -
Usage: easypy [options] <jobfile> [arguments] Easypy: error: the following arguments are required: jobfile
cause No jobfile or test script was provided as an argument to `easypy`.fixProvide the path to your test script (e.g., `my_test.py`) or a job file (e.g., `my_job.py`) after the `easypy` command: `easypy my_test.py`. -
KeyError: 'devices'
cause Your test script is attempting to access a testbed device (e.g., `self.runtime.testbed.devices`) but no testbed file was provided or it's invalid.fixProvide a valid testbed YAML file using the `--testbed-file` argument when running `easypy`, e.g., `easypy my_test.py --testbed-file /path/to/my_testbed.yaml`. -
ERROR: Plugin 'X' failed to load: No module named 'Y'
cause A custom pyATS plugin (or a plugin's dependency) specified in your environment or job file is not installed or discoverable.fixInstall the missing plugin package using pip (e.g., `pip install pyats.plugin.myplugin`) or ensure its path is correctly added to `PYTHONPATH` if it's a local module.
Warnings
- breaking Major pyATS versions (and thus pyats-easypy) can introduce breaking changes in testbed YAML schema or plugin APIs. Always consult release notes when upgrading across major versions (e.g., 24.x to 25.x).
- gotcha Easypy relies heavily on environment variables for configuration (e.g., `AE_TESTBED`, `AE_RESULTS_DIR`). Incorrectly set or missing environment variables can lead to unexpected behavior or failures, especially in CI/CD pipelines.
- gotcha The `easypy` command-line tool requires an AETest script (or a job file) as an argument. Simply running `python your_script.py` for an AETest script will not invoke the Easypy runtime and its features (plugins, reporting, etc.).
- deprecated Older versions of pyATS might have supported Python 3.6 or 3.7, but current versions of `pyats-easypy` (26.x) explicitly require Python 3.8 and above. Attempting to install or run on older Python versions will fail.
Install
-
pip install pyats-easypy
Imports
- aetest
from pyats import aetest
- main
import easypy
from pyats.easypy import main
Quickstart
import os
from pyats import aetest
class CommonSetup(aetest.CommonSetup):
@aetest.subsection
def initial_setup(self):
self.parent.parameters['example_param'] = 'Hello, pyATS!'
self.log.info(f"Running initial setup with param: {self.parent.parameters['example_param']}")
class Testcase1(aetest.Testcase):
@aetest.test
def example_test(self):
param = self.parent.parameters['example_param']
self.log.info(f"Executing example_test with param: {param}")
assert param == 'Hello, pyATS!'
class CommonCleanup(aetest.CommonCleanup):
@aetest.subsection
def final_cleanup(self):
self.log.info("Running final cleanup.")
# To run this script:
# 1. Save it as e.g., `my_test.py`
# 2. Run from your terminal: `easypy my_test.py`
# Optional: To specify a testbed (e.g., if tests use device connections):
# `easypy my_test.py --testbed-file my_testbed.yaml`
# For quick demo, --testbed-file isn't strictly needed for this simple test.