This lesson is part of the Network Testing with Pytest course.
In this lesson, you will learn:
- How to share fixtures between our tests.
- How to refactor our Scrapli example to use shared fixtures.
You can find the scripts and code for this lesson within the Pytest repo under the directory: 003_fixtures/003_conftest.
Introduction to conftest.py
A question that you may now be asking is:
How can I share fixtures across multiple test files?
The answer is conftest.py
. By creating a file named conftest.py
, any fixtures that we place within it will then be shared across other fixtures and tests within our other files.
Let's look at an example.