]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Replace tearDown with addCleanup - Part 5
authorJulia Varlamova <jvarlamova@mirantis.com>
Thu, 27 Feb 2014 14:31:29 +0000 (18:31 +0400)
committerGerrit Code Review <review@openstack.org>
Tue, 15 Apr 2014 13:51:14 +0000 (13:51 +0000)
Replace tearDown with addCleanup in:
- cinder/test.py
- cinder/tests/test_migrations.py

Remove empty tearDown methods from:
- cinder/tests/test_hp3par.py
- cinder/tests/test_hplefthand.py
- cinder/tests/test_ibmnas.py
since it does not add any functionality (and empty setUp methods as well).

Infra team has indicated that tearDown should not be used and should
be replaced with addCleanup in all places.

Implements blueprint replace-teardown-with-addcleanup

Change-Id: Id2fdd3e2e1ab8458083697b6ea6714ca019fd00a

cinder/test.py
cinder/tests/test_hp3par.py
cinder/tests/test_hplefthand.py
cinder/tests/test_ibmnas.py
cinder/tests/test_migrations.py

index 2f6b887dfe78cc5413375a2cb64883b64721ef66..b394f4102ffb8d4163607295887666ea1827c33c 100644 (file)
@@ -173,6 +173,7 @@ class TestCase(testtools.TestCase):
         self.addCleanup(self.stubs.UnsetAll)
         self.addCleanup(self.stubs.SmartUnsetAll)
         self.addCleanup(self.mox.VerifyAll)
+        self.addCleanup(self._common_cleanup)
         self.injected = []
         self._services = []
 
@@ -182,7 +183,7 @@ class TestCase(testtools.TestCase):
         # This will be cleaned up by the NestedTempfile fixture
         CONF.set_override('lock_path', tempfile.mkdtemp())
 
-    def tearDown(self):
+    def _common_cleanup(self):
         """Runs after each test method to tear down test environment."""
 
         # Stop any timers
@@ -204,7 +205,6 @@ class TestCase(testtools.TestCase):
         # suite
         for key in [k for k in self.__dict__.keys() if k[0] != '_']:
             del self.__dict__[key]
-        super(TestCase, self).tearDown()
 
     def flags(self, **kw):
         """Override CONF variables for a test."""
index 119f6c4040bcea9261ca9a330e3f988f1db8fbd0..4ad126cfb81f8a17286e20fdd90759cc44a88362 100644 (file)
@@ -934,12 +934,6 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
                                      ['0987654321234', '123456789000987'],
                                      }}}
 
-    def setUp(self):
-        super(TestHP3PARFCDriver, self).setUp()
-
-    def tearDown(self):
-        super(TestHP3PARFCDriver, self).tearDown()
-
     def setup_driver(self, config=None, mock_conf=None):
 
         self.ctxt = context.get_admin_context()
@@ -1264,12 +1258,6 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
             'target_lun': TARGET_LUN,
             'target_portal': '1.1.1.2:1234'}}
 
-    def setUp(self):
-        super(TestHP3PARISCSIDriver, self).setUp()
-
-    def tearDown(self):
-        super(TestHP3PARISCSIDriver, self).tearDown()
-
     def setup_driver(self, config=None, mock_conf=None):
 
         self.ctxt = context.get_admin_context()
index 040ad86bf85936405f7ce15cef30f82cd3c16355..654a5ddc18e499306e5eedb5193647a4b6b59e99 100644 (file)
@@ -340,9 +340,6 @@ class TestHPLeftHandCLIQISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
             'iqn.2003-10.com.lefthandnetworks:group01:25366:fakev',
             'volume_id': self.volume_id}
 
-    def tearDown(self):
-        super(TestHPLeftHandCLIQISCSIDriver, self).tearDown()
-
     def default_mock_conf(self):
 
         mock_conf = mock.Mock()
@@ -601,12 +598,6 @@ class TestHPLeftHandRESTISCSIDriver(HPLeftHandBaseDriver, test.TestCase):
         mock.call.getClusterByName('CloudCluster1'),
         mock.call.getCluster(1)]
 
-    def setUp(self):
-        super(TestHPLeftHandRESTISCSIDriver, self).setUp()
-
-    def tearDown(self):
-        super(TestHPLeftHandRESTISCSIDriver, self).tearDown()
-
     def default_mock_conf(self):
 
         mock_conf = mock.Mock()
index 8105eb61ab43ef957f23fd9dc085086371fed396..bff55d3d06f2de32e201ee0858f172b37a33f9f1 100644 (file)
@@ -79,9 +79,6 @@ class IBMNASDriverTestCase(test.TestCase):
         self.context.user_id = 'fake'
         self.context.project_id = 'fake'
 
-    def tearDown(self):
-        super(IBMNASDriverTestCase, self).tearDown()
-
     def _set_flag(self, flag, value):
         group = self._driver.configuration.config_group
         self._driver.configuration.set_override(flag, value, group)
index bba727a17f6379d8d6fd00b27b1e51b4fed4aea7..d3ec208f3248022752e067d752c56c1e770bfd40 100644 (file)
@@ -162,13 +162,10 @@ class TestMigrations(test.TestCase):
         # We start each test case with a completely blank slate.
         self._reset_databases()
 
-    def tearDown(self):
-
         # We destroy the test data store between each test case,
         # and recreate it, which ensures that we have no side-effects
         # from the tests
-        self._reset_databases()
-        super(TestMigrations, self).tearDown()
+        self.addCleanup(self._reset_databases)
 
     def _reset_databases(self):
         def execute_cmd(cmd=None):