Add mock.patch.stopall() to rally test cleanup

* using stopall() to stop patches avoids race conditions
  that might arise when mock state is not cleaned up
  between test cases
* use of stopall() from test case cleanup is recommended
  when applying patches as part setUp()

Change-Id: I7918cc8c7c96a25ae874ea8bede93719d6baa634
This commit is contained in:
Marco Morais 2014-04-30 18:43:48 +00:00
parent 5a8dc964ad
commit 9978d0855e

View File

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from oslotest import base
from rally import db
@ -31,7 +33,10 @@ class DatabaseFixture(config.Config):
class TestCase(base.BaseTestCase):
"""Test case base class for all unit tests."""
pass
def setUp(self):
super(TestCase, self).setUp()
self.addCleanup(mock.patch.stopall)
class DBTestCase(TestCase):