From the course: Unit Testing in Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Modularizing conftest.py

Modularizing conftest.py - Python Tutorial

From the course: Unit Testing in Python

Start my 1-month free trial

Modularizing conftest.py

- [Instructor] In the previous example, our conftest.py file held two fixtures but imagine what would happen if your system grew. This file could grow to contain a large amount of fixtures giving each one limited visibility. One way to overcome this problem is to modularize your fixtures or store them in their own directories. Then you can import them into conftest.py and use them as you had before. You can achieve this in a few ways. I'll show you two that I'm familiar with. Before we begin, you'll notice that this file, conftest_start.py is nested under our test directory two levels deep. It's under chapter four, video two. This file is being shown for walkthrough purposes only. Normally, conftest.py should be located directly under the test folder. This gives other tests the ability to access its fixtures and functions directly. To achieve modularization, first, let's delete our fixtures from conftest.py. Make…

Contents