From 827547a0b3da411441bf691ddbc94867001a3311 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 22 Jan 2013 19:54:57 -0500 Subject: Use testtools as test base class. On the path to testr migration, we need to replace the unittest base classes with testtools. Replace tearDown with addCleanup, addCleanup is more resilient than tearDown. The fixtures library has excellent support for managing and cleaning tempfiles. Use it. Replace skip_ with testtools.skipTest Part of blueprint grizzly-testtools. Change-Id: I45e11bbb1ff9b31f3278d3b016737dcb7850cd98 --- tests/utils.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'tests/utils.py') diff --git a/tests/utils.py b/tests/utils.py index 883e5f6..2cbcd5b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -19,24 +19,20 @@ import stubout import subprocess -import unittest +import testtools from openstack.common import cfg +from openstack.common.fixture import moxstubout CONF = cfg.CONF -class BaseTestCase(unittest.TestCase): +class BaseTestCase(testtools.TestCase): def setUp(self): super(BaseTestCase, self).setUp() - self.stubs = stubout.StubOutForTesting() - - def tearDown(self): - super(BaseTestCase, self).tearDown() - CONF.reset() - self.stubs.UnsetAll() - self.stubs.SmartUnsetAll() + self.stubs = self.useFixture(moxstubout.MoxStubout()).stubs + self.addCleanup(CONF.reset) def config(self, **kw): """ -- cgit