From 7787ef3b0aeb0448e60c30afe13d5a5bc164f44e Mon Sep 17 00:00:00 2001 From: Van Hung Pham Date: Fri, 23 Jun 2017 16:38:12 +0700 Subject: [PATCH] Using assertFalse(A) instead of assertEqual(False, A) This patch is to replace assertEqual(False, A) with assertFalse(A), which the latter is more straightforward and easier to understand. Similar to a merged patch https://review.openstack.org/#/c/473749/ Change-Id: I056c2840ed431e3c792f5f1f70f9e7d9e4e22d0b --- tacker/tests/unit/test_attributes.py | 28 ++++++++++++++-------------- tacker/tests/unit/test_auth.py | 2 +- tacker/tests/unit/test_policy.py | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tacker/tests/unit/test_attributes.py b/tacker/tests/unit/test_attributes.py index 0682425a1..a95273892 100644 --- a/tacker/tests/unit/test_attributes.py +++ b/tacker/tests/unit/test_attributes.py @@ -43,13 +43,13 @@ class TestAttributes(base.BaseTestCase): def test_is_attr_set(self): data = attributes.ATTR_NOT_SPECIFIED - self.assertIs(attributes.is_attr_set(data), False) + self.assertFalse(attributes.is_attr_set(data)) data = None - self.assertIs(attributes.is_attr_set(data), False) + self.assertFalse(attributes.is_attr_set(data)) data = "I'm set" - self.assertIs(attributes.is_attr_set(data), True) + self.assertTrue(attributes.is_attr_set(data)) def test_validate_values(self): msg = attributes._validate_values(4, [4, 6]) @@ -647,7 +647,7 @@ class TestAttributes(base.BaseTestCase): self.assertIsNone(msg) # Explicitly comparing with literal 'True' as assertTrue # succeeds also for 'true' - self.assertIs(True, dictionary['key_bool']) + self.assertTrue(dictionary['key_bool']) def test_subdictionary(self): dictionary, constraints = self._construct_dict_and_constraints() @@ -693,23 +693,23 @@ class TestAttributes(base.BaseTestCase): class TestConvertToBoolean(base.BaseTestCase): def test_convert_to_boolean_bool(self): - self.assertIs(attributes.convert_to_boolean(True), True) - self.assertIs(attributes.convert_to_boolean(False), False) + self.assertTrue(attributes.convert_to_boolean(True)) + self.assertFalse(attributes.convert_to_boolean(False)) def test_convert_to_boolean_int(self): - self.assertIs(attributes.convert_to_boolean(0), False) - self.assertIs(attributes.convert_to_boolean(1), True) + self.assertFalse(attributes.convert_to_boolean(0)) + self.assertTrue(attributes.convert_to_boolean(1)) self.assertRaises(n_exc.InvalidInput, attributes.convert_to_boolean, 7) def test_convert_to_boolean_str(self): - self.assertIs(attributes.convert_to_boolean('True'), True) - self.assertIs(attributes.convert_to_boolean('true'), True) - self.assertIs(attributes.convert_to_boolean('False'), False) - self.assertIs(attributes.convert_to_boolean('false'), False) - self.assertIs(attributes.convert_to_boolean('0'), False) - self.assertIs(attributes.convert_to_boolean('1'), True) + self.assertTrue(attributes.convert_to_boolean('True')) + self.assertTrue(attributes.convert_to_boolean('true')) + self.assertFalse(attributes.convert_to_boolean('False')) + self.assertFalse(attributes.convert_to_boolean('false')) + self.assertFalse(attributes.convert_to_boolean('0')) + self.assertTrue(attributes.convert_to_boolean('1')) self.assertRaises(n_exc.InvalidInput, attributes.convert_to_boolean, '7') diff --git a/tacker/tests/unit/test_auth.py b/tacker/tests/unit/test_auth.py index 42cfff50d..c9d552337 100644 --- a/tacker/tests/unit/test_auth.py +++ b/tacker/tests/unit/test_auth.py @@ -65,7 +65,7 @@ class TackerKeystoneContextTestCase(base.BaseTestCase): self.assertEqual(['role1', 'role2', 'role3', 'role4', 'role5'], self.context.roles) - self.assertEqual(False, self.context.is_admin) + self.assertFalse(self.context.is_admin) def test_roles_with_admin(self): self.request.headers['X_PROJECT_ID'] = 'testtenantid' diff --git a/tacker/tests/unit/test_policy.py b/tacker/tests/unit/test_policy.py index 9d1d446fc..c91d6dfd0 100644 --- a/tacker/tests/unit/test_policy.py +++ b/tacker/tests/unit/test_policy.py @@ -108,7 +108,7 @@ class PolicyTestCase(base.BaseTestCase): def test_check_bad_action_noraise(self): action = "example:denied" result = policy.check(self.context, action, self.target) - self.assertEqual(False, result) + self.assertFalse(result) def test_check_non_existent_action(self): action = "example:idonotexist"