""" This module loads pytest fixtures and plugins needed by all tests. It's very useful for fixtures that need to be shared among all tests. """ import pytest @pytest.fixture() def test_datadir(request, datadir): """ Inject the datadir with resources for the specific test function. If the test function is declared in a class then datadir is ClassName/FunctionName otherwise it is only FunctionName. """ function_name = request.function.__name__ if not request.cls: return datadir / function_name class_name = request.cls.__name__ return datadir / class_name / function_name