]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Utilizes assertIsNotNone
authorZhongyue Luo <zhongyue.nah@intel.com>
Fri, 6 Sep 2013 04:01:26 +0000 (12:01 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Fri, 6 Sep 2013 04:02:43 +0000 (12:02 +0800)
Using assertTrue and the 'is not' operator to test if an element
is not None is too python2.4. Our unit testing framework supports
assertIsNotNone, included from python 2.7, which was created
for these types of tests.

Change-Id: I25c3f2b144357a3f86625deb8e324d78c20b9ce4

cinder/tests/scheduler/test_filter_scheduler.py
cinder/tests/test_hp3par.py

index e9f673ce8a4933fa464b617b3ea46c6966cec7ff..f5a7a4d0ef18247aa385f989f4e7dbec10497553 100644 (file)
@@ -94,7 +94,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
                                               'size': 1}}
         self.mox.ReplayAll()
         weighed_host = sched._schedule(fake_context, request_spec, {})
-        self.assertTrue(weighed_host.obj is not None)
+        self.assertIsNotNone(weighed_host.obj)
 
     def test_max_attempts(self):
         self.flags(scheduler_max_attempts=4)
index 011c471722eb089d1efed08219fa43c84416bfd1..ed568b2fd2e275128b3d477008ff882895063761 100644 (file)
@@ -566,7 +566,7 @@ class HP3PARBaseDriver():
                   'source_volid': HP3PARBaseDriver.VOLUME_ID}
         src_vref = {}
         model_update = self.driver.create_cloned_volume(volume, src_vref)
-        self.assertTrue(model_update is not None)
+        self.assertIsNotNone(model_update)
 
     def test_create_snapshot(self):
         self.flags(lock_path=self.tempdir)