From 1c12c4db4eacdb696437dbd1552c67c7541bfba5 Mon Sep 17 00:00:00 2001 From: Zhongyue Luo Date: Fri, 30 Aug 2013 22:12:29 +0800 Subject: [PATCH] Remove deprecated assert_() usage 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 | 2 +- cinder/tests/test_misc.py | 2 +- cinder/tests/test_policy.py | 8 ++++---- cinder/tests/test_service.py | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cinder/tests/api/test_extensions.py b/cinder/tests/api/test_extensions.py index d46dbcad5..5a9383291 100644 --- a/cinder/tests/api/test_extensions.py +++ b/cinder/tests/api/test_extensions.py @@ -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'] diff --git a/cinder/tests/test_misc.py b/cinder/tests/test_misc.py index 60ad26b7e..1fbf0091c 100644 --- a/cinder/tests/test_misc.py +++ b/cinder/tests/test_misc.py @@ -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) diff --git a/cinder/tests/test_policy.py b/cinder/tests/test_policy.py index a65fc66ad..a6259c295 100644 --- a/cinder/tests/test_policy.py +++ b/cinder/tests/test_policy.py @@ -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) diff --git a/cinder/tests/test_service.py b/cinder/tests/test_service.py index 1af498385..bae042a27 100644 --- a/cinder/tests/test_service.py +++ b/cinder/tests/test_service.py @@ -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): -- 2.45.2