The below code runs after every function including the setup class. I dont create an instance before the actual tests so i don't want it to run after the setup_class method. Can you advise if i can change the signature to not run after setup class
@pytest.fixture(autouse=True)
def teardown_module(self):
Log.test_teardown("Deleting instance")
Utils.compute_utils().delete_instance_and_wait_for_state(
TestAutoValidateCpuAlignment.instance_id, teardown=True)
This can be done more efficiently using
yield
. Combine theteardown_module
and thecreate_module
fixtures into one that does both andyield
between the operations. This way it will create your instance, execute the tests and then tear it down.