Merge "Call tearDownClass when handling skip exception on setUpClass"

This commit is contained in:
Zuul 2019-10-02 02:23:19 +00:00 committed by Gerrit Code Review
commit 420155c234
2 changed files with 6 additions and 1 deletions

View File

@ -203,6 +203,10 @@ class BaseTestCase(testtools.testcase.WithAttributes,
cls._teardowns.append(('resources', cls.resource_cleanup))
cls.resource_setup()
except exc as e:
# NOTE(dviroel): the exception may be raised after setting up the
# user credentials, so we must call tearDownClass to release all
# allocated resources.
cls.tearDownClass()
raise exc_to_raise(e.args)
except Exception:
etype, value, trace = sys.exc_info()

View File

@ -538,7 +538,8 @@ class TestTempestBaseTestClassFixtures(base.TestCase):
result = LoggingTestResult(log)
suite.run(result)
# If we trigger a skip condition, teardown is not invoked at all
self.assertEqual(self.SETUP_FIXTURES[:2],
self.assertEqual((self.SETUP_FIXTURES[:2] +
[self.TEARDOWN_FIXTURES[0]]),
self.test.fixtures_invoked)
def test_skip_credentials_fails(self):