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.

Members Only Content
Want to Learn Network Automation?
Join our membership to access:
  • 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
  • Tech demos and sessions

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.