Skip SharedFixture.cleanUp during check-resources steps

The SharedFixture.cleanUp method is called when setup_fixture fails. The
aim of this is to delete the resources that were not successfully
created and allow next tests to create them properly.
This is not valid with check-resources steps because resources are not
created again.
So, in this case, it makes more sense to skip deletion of resources and
run the rest of tests with the existing ones, even if they fail.

Change-Id: I11b4eb5178c9891a692836ef720ca0487f407e60
This commit is contained in:
Eduardo Olivares 2023-09-27 11:59:19 +02:00
parent 715d6c9361
commit c2f03aff50

View File

@ -568,7 +568,11 @@ class SharedFixture(fixtures.Fixture):
def cleanUp(self, raise_first=True):
"""Executes registered cleanups if any"""
if not self._cleanup_executed:
from tobiko import config
if config.get_bool_env('TOBIKO_PREVENT_CREATE'):
LOG.debug('Skipping %r fixture cleanup due to '
'TOBIKO_PREVENT_CREATE', self.fixture_name)
elif not self._cleanup_executed:
LOG.debug('Clean up fixture %r', self.fixture_name)
self.addCleanup(self.cleanup_fixture)
result = super(SharedFixture, self).cleanUp(raise_first=raise_first)