The other day I was asked,

what is the difference between Pytest and pyATS?

With the huge amount of tools and frameworks available to us now for network automation, I thought this was a great question and something I thought I would quickly answer in this post today.

So first of all ...

What is Pytest?

Pytest is a Python testing framework. It allows you to write tests in Python, using the Python assert keyword, to validate a condition is True. Like so:

def test_vlan():
    device_vlan = "100"
    expected_vlan = "101"

    assert device_vlan == expected_vlan

Pytest provides a CLI, run-time, and build test framework. Therefore, we will still need to add whatever other tools we need to collect information from the network, parse the data, etc. Below is an example Pytest stack:

  • To output reports within Pytest, a plugin is required.
  • To collect the data Netmiko is required.
  • To parse the data with Netmiko, we need to install the required parsing library (Genie, TextFSM, TTP etc.).

What is pyATS?

Whereas Pytest provides the testing framework and test execution. pyATS is a full-blown (also Python-based) testing framework that includes:

  • Parsers
  • Various libraries for performing differentials (Genie Diff) and abstracting the commands you need to run (Genie Learn).
  • Testing runtime and execution (AETest and Easypy)
  • Testing addons such as HTML reports etc.
  • Libraries for connecting to devices (Unicon).

Below is an example...

When to Use What?

pyATS is great, and you can get some super quick wins. But with it being a full framework, it can become tricky to do things outside of what the framework provides. For example, let's say you wanted to use Scrapli to connect to the devices or use parsers from a library outside of the Genie parsers such as TextFSM.

This is where Pytest is great as it allows you to completely decouple your testing stack. Yes, you may not have everything there out of the box and need to create a little more boilerplate code in places, but with this you get flexibility.

If you want to learn more about Pytest or pyATS check out our courses below:

Network Testing with Pytest
Learn how to structure and build tests to validate your network using Pytest. Along with how to integrate Pytest with Scrapli, Nornir, NAPALM, Batfish, and Suzieq.
Network Testing with Cisco pyATS
Deep-dive Cisco pyATS training, lab included. You will learn how to configure devices, parse output, compare network states and more.
Want to Learn Network Automation?
Join our membership and get access to:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Tech demos and sessions

Join Now ➜