Middle
What is a conftest.py file and how many such files can be in a project?
sobes.tech AI
Answer from AI
The conftest.py file is used in the pytest framework to define common fixtures, hooks, and configurations that will be available in all tests within the current directory and its subdirectories.
There may be multiple conftest.py files located in different folders within the project, allowing for local overrides or additions of fixtures and configurations for specific test sets.
Example of a fixture in conftest.py:
import pytest
@pytest.fixture
def db_connection():
conn = create_connection()
yield conn
conn.close()