In this lesson, you will learn:

  • What fixtures are.
  • About the fixture decorator.
  • How to display your fixtures via the CLI.

You can find the scripts and code for this lesson within the Pytest repo under the directory: 003_fixtures/001_intro.

What Are Fixtures?

Pytest fixtures are functions that run prior to test execution. The role of a fixture is to provide our tests with anything that it may need in order to run. For example, our test may need data. In fact, it may need data pulled from an external source (say, via a NetBox API). Or our test may require a test device to be spun up, then deleted after the tests are complete. All these things are actions and operations that can be performed by Pytest fixtures.

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.