]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Remove deprecated assert_() usage
authorZhongyue Luo <zhongyue.nah@intel.com>
Fri, 30 Aug 2013 14:12:29 +0000 (22:12 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Fri, 6 Sep 2013 01:02:50 +0000 (09:02 +0800)
The method assert_() is an alias of assertTrue() and
is deprecated since python 2.7

http://docs.python.org/2/library/unittest.html#deprecated-aliases

This removes all assert_() uses.

Change-Id: I9f55c442cc2416a7aa2dac569d1750f723d95184

cinder/tests/api/test_extensions.py
cinder/tests/test_misc.py
cinder/tests/test_policy.py
cinder/tests/test_service.py

index d46dbcad50e684685aab2ca530810105f1238b8c..5a938329194abdcbcbeb01d460022a9cc5f300a7 100644 (file)
@@ -119,7 +119,7 @@ class ExtensionControllerTest(ExtensionTestCase):
 
         # Make sure we have all the extensions, extras extensions being OK.
         exts = root.findall('{0}extension'.format(NS))
-        self.assert_(len(exts) >= len(self.ext_list))
+        self.assertTrue(len(exts) >= len(self.ext_list))
 
         # Make sure that at least Fox in Sox is correct.
         (fox_ext, ) = [x for x in exts if x.get('alias') == 'FOXNSOX']
index 60ad26b7ed81ffa883f8a31e860e58f3bab0f865..1fbf0091c1274d766d7ad6d44d48dbc24e85d047 100644 (file)
@@ -58,4 +58,4 @@ class ProjectTestCase(test.TestCase):
 
         helpful_msg = (_("The following migrations are missing a downgrade:"
                          "\n\t%s") % '\n\t'.join(sorted(missing_downgrade)))
-        self.assert_(not missing_downgrade, helpful_msg)
+        self.assertFalse(missing_downgrade, msg=helpful_msg)
index a65fc66ad95a1fd8dd7b94d7712e7418d709a781..a6259c295bd52ae7d82f40ea0b64e2241a54c07a 100644 (file)
@@ -204,7 +204,7 @@ class ContextIsAdminPolicyTestCase(test.TestCase):
         ctx = context.RequestContext('fake', 'fake', roles=['johnny-admin'])
         self.assertFalse(ctx.is_admin)
         ctx = context.RequestContext('fake', 'fake', roles=['admin'])
-        self.assert_(ctx.is_admin)
+        self.assertTrue(ctx.is_admin)
 
     def test_custom_admin_role_is_admin(self):
         # define explict rules for context_is_admin
@@ -214,9 +214,9 @@ class ContextIsAdminPolicyTestCase(test.TestCase):
         brain = common_policy.Brain(rules, CONF.policy_default_rule)
         common_policy.set_brain(brain)
         ctx = context.RequestContext('fake', 'fake', roles=['johnny-admin'])
-        self.assert_(ctx.is_admin)
+        self.assertTrue(ctx.is_admin)
         ctx = context.RequestContext('fake', 'fake', roles=['administrator'])
-        self.assert_(ctx.is_admin)
+        self.assertTrue(ctx.is_admin)
         # default rule no longer applies
         ctx = context.RequestContext('fake', 'fake', roles=['admin'])
         self.assertFalse(ctx.is_admin)
@@ -231,4 +231,4 @@ class ContextIsAdminPolicyTestCase(test.TestCase):
         ctx = context.RequestContext('fake', 'fake')
         self.assertFalse(ctx.is_admin)
         ctx = context.RequestContext('fake', 'fake', roles=['admin'])
-        self.assert_(ctx.is_admin)
+        self.assertTrue(ctx.is_admin)
index 1af498385b50034fb5774c129d799f340b5b70cf..bae042a27ef401df9d9036a2c705a6db211486d4 100644 (file)
@@ -94,7 +94,7 @@ class ServiceFlagsTestCase(test.TestCase):
         app.stop()
         ref = db.service_get(context.get_admin_context(), app.service_id)
         db.service_destroy(context.get_admin_context(), app.service_id)
-        self.assert_(not ref['disabled'])
+        self.assertFalse(ref['disabled'])
 
     def test_service_disabled_on_create_based_on_flag(self):
         self.flags(enable_new_services=False)
@@ -105,7 +105,7 @@ class ServiceFlagsTestCase(test.TestCase):
         app.stop()
         ref = db.service_get(context.get_admin_context(), app.service_id)
         db.service_destroy(context.get_admin_context(), app.service_id)
-        self.assert_(ref['disabled'])
+        self.assertTrue(ref['disabled'])
 
 
 class ServiceTestCase(test.TestCase):
@@ -124,7 +124,7 @@ class ServiceTestCase(test.TestCase):
         #             the looping calls are created in StartService.
         app = service.Service.create(host=host, binary=binary, topic=topic)
 
-        self.assert_(app)
+        self.assertTrue(app)
 
     def test_report_state_newly_disconnected(self):
         host = 'foo'
@@ -157,7 +157,7 @@ class ServiceTestCase(test.TestCase):
                                'cinder.tests.test_service.FakeManager')
         serv.start()
         serv.report_state()
-        self.assert_(serv.model_disconnected)
+        self.assertTrue(serv.model_disconnected)
 
     def test_report_state_newly_connected(self):
         host = 'foo'
@@ -194,7 +194,7 @@ class ServiceTestCase(test.TestCase):
         serv.model_disconnected = True
         serv.report_state()
 
-        self.assert_(not serv.model_disconnected)
+        self.assertFalse(serv.model_disconnected)
 
 
 class TestWSGIService(test.TestCase):