the setup and teardown methods for the module are executed at the beginning and end of the session then the lone module-level test function is run nextthe setup method for the first class is executedfollowed by the two tests for that class these tests are each individually wrapped in separate setup_method and teardown_method calls after the tests have executedthe class teardown method is called the same sequence happens for the second classbefore the teardown_module method is finally calledexactly once completely different way to set up variables one of the most common uses for the various setup and teardown functions is to ensure certain class or module variables are available with known value before each test method is run py test offers completely different way to do this using what are known as funcargsshort for function arguments funcargs are basically named variables that are predefined in test configuration file this allows us to separate configuration from execution of testsand allows the funcargs to be used across multiple classes and modules to use themwe add parameters to our test function the names of the parameters are used to look up specific arguments in specially named functions for exampleif we wanted to test the statslist class we used while demonstrating unittestwe would again want to repeatedly test list of valid integers but we can write our tests like so instead of using setup methodfrom stats import statslist def pytest_funcarg__valid_stats(request)return statslist([ , , , , , ]def test_mean(valid_stats)assert valid_stats mean(= def test_median(valid_stats)assert valid_stats median(= valid_stats append( assert valid_stats median(= def test_mode(valid_stats)assert valid_stats mode(=[ , valid_stats remove( assert valid_stats mode(=[