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