In this lesson, you will learn:

  • What is parametrization.
  • Why we need parametrization.

You can find the scripts and code for this lesson within the Pytest repo under the directory: 004_parametrization/001_no_parametrization.

Testing Without Parametrization

Based on what we have learnt, let’s say we wanted to test for multiple VLANs on a device. To do so, we could write our test like this:

import pytest

@pytest.fixture(scope="session")
def expected_vlan():
    return ["100", "101", "102"]

@pytest.fixture()
def device_vlans():
    return ["100"]

def test_vlan(expected_vlan, device_vlans):
    for vlan in expected_vlan:
        assert vlan in device_vlans
Ready to Master Network Automation? Start Your Journey Today!
Our membership provides:
  • 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
  • Live monthly tech sessions
  • Access to tech session library

Join Now ➜
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.