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.

Using Conftest.py for common functions

Using Conftest.py for common functions - Python Tutorial

From the course: Unit Testing in Python

Start my 1-month free trial

Using Conftest.py for common functions

- [Instructor] When you create a test suite, you may realize that you are using common test fixtures across multiple separate test files. With conftest.py, we can store these common utility test fixtures there and access them globally within the testing suite. Functions housed within conftest.py act as plug-ins that contain directory specific extension code that the base code in your test can call. This extension code is often referred to as hook implementations. This can be useful when you want to offer such extensibility without code duplication. It's also helpful when you don't want certain non-essential setup or utility functions to be exposed in the code. Additionally, if you're ever reading another developer's test suite and spot test function parameters that are not mentioned either in the file as fixtures or functions, then you should check the conftest.py file to see if those parameters reference a test fixture…

Contents