This lesson is part of the Network Testing with Pytest course.
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