If you mean only once in each test case run, then tuning and disassembling is what you are looking for
def setup_module(module): print ("This will at start of module") def teardown_module(module): print ("This will run at end of module")
Similarly, you can have setup_function and teardown_function that will run at the beginning and at the end of each test function in turn. You can also add a tuning and breaking member function to the test classes to run at the beginning and end of the test class.
source share