From 11f4b627459cb68b199ad4f2f1738f07f27627bc Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Tue, 6 Jun 2017 22:47:49 +0000 Subject: [PATCH] Reset the _TRAITS_SYNCED global in Traits tests The global is reset before and after tests because we don't know what other tests might have been messing with it (without even knowing) in this process. We want to start from a clean slate and leave the slate clean. Change-Id: I42b9a7973ec5c4f42578779dc6ad59274212113f Closes-Bug: #1696267 --- nova/tests/functional/db/test_resource_provider.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/nova/tests/functional/db/test_resource_provider.py b/nova/tests/functional/db/test_resource_provider.py index 5450e8e0b6..c95bc88cf7 100644 --- a/nova/tests/functional/db/test_resource_provider.py +++ b/nova/tests/functional/db/test_resource_provider.py @@ -1536,9 +1536,17 @@ class ResourceClassTestCase(ResourceProviderBaseCase): class ResourceProviderTraitTestCase(ResourceProviderBaseCase): - def tearDown(self): - """Reset the _TRAITS_SYNCED boolean so it doesn't interfere.""" - super(ResourceProviderTraitTestCase, self).tearDown() + def setUp(self): + super(ResourceProviderTraitTestCase, self).setUp() + # Reset the _TRAITS_SYNCED global before we start and after + # we are done since other tests (notably the gabbi tests) + # may have caused it to change. + self._reset_traits_synced() + self.addCleanup(self._reset_traits_synced) + + @staticmethod + def _reset_traits_synced(): + """Reset the _TRAITS_SYNCED boolean to base state.""" rp_obj._TRAITS_SYNCED = False def _assert_traits(self, expected_traits, traits_objs):