each of the three test methods accepts parameter named valid_statsthis parameter is created by calling the pytest_funcarg__valid_stats function defined at the top of the file it can also be defined in file called conftest py if the funcarg is needed by multiple modules the conftest py file is parsed by py test to load any "globaltest configurationit is sort of catch-all for customizing the py test experience as with other py test featuresthe name of the factory for returning funcarg is importantfuncargs are functions that are named pytest_funcarg__where is valid variable name that can be used as parameter in test function this function accepts mysterious request parameterand returns the object to be passed as an argument into the individual test functions the funcarg is created afresh for each call to an individual test functionthis allows usfor exampleto change the list in one test and know that it will be reset to its original values in the next test funcargs can do lot more than return basic variables that request object passed into the funcarg factory provides some extremely useful methods and attributes to modify the funcarg' behavior the moduleclsand function attributes allow us to see exactly which test is requesting the funcarg the config attribute allows us to check command-line arguments and other configuration data more interestinglythe request object provides methods that allow us to do additional cleanup on the funcargor to reuse it across testsactivities that would otherwise be relegated to setup and teardown methods of specific scope the request addfinalizer method accepts callback function that performs cleanup after each test function that uses the funcarg has been called this provides the equivalent of teardown methodallowing us to clean up filesclose connectionsempty listsor reset queues for examplethe following code tests the os mkdir functionality by creating temporary directory funcargimport tempfile import shutil import os path def pytest_funcarg__temp_dir(request)dir tempfile mkdtemp(print(dirdef cleanup()shutil rmtree(dirrequest addfinalizer(cleanup