Modify use of assertTrue(A in B)

Developers should use assertIn(A, B) instead of assertTrue(A in B ).

TrivialFix

Change-Id: I6f2b33e73ff3ebf28a681021d58c9b2485a016fd
This commit is contained in:
Bin Zhou 2016-09-02 13:10:32 +08:00
parent ba86557ed2
commit e3a2432bf7
4 changed files with 8 additions and 8 deletions

View File

@ -48,7 +48,7 @@ class ResourceTypeConstraintTest(common.HeatTestCase):
# Verify
self.assertFalse(result)
self.assertTrue('OS::Heat::None' in self.constraint._error_message)
self.assertIn('OS::Heat::None', self.constraint._error_message)
self.mock_env.get_class.assert_called_once_with(value[0])
def test_validate_multiple_failures(self):

View File

@ -121,7 +121,7 @@ class ResourceChainTest(common.HeatTestCase):
# No error, but no resources to create
self.assertTrue('resources' not in tmpl)
# Sanity check that it's actually a template
self.assertTrue('heat_template_version' in tmpl)
self.assertIn('heat_template_version', tmpl)
def test_validate_nested_stack(self):
# Test - should not raise exception
@ -145,7 +145,7 @@ class ResourceChainTest(common.HeatTestCase):
chain.validate_nested_stack()
self.fail('Exception expected')
except exception.StackValidationFailed as e:
self.assertTrue('unknown property group' in e.message.lower())
self.assertIn('unknown property group', e.message.lower())
def test_validate_fake_resource_type(self):
# Setup
@ -161,8 +161,8 @@ class ResourceChainTest(common.HeatTestCase):
chain.validate_nested_stack()
self.fail('Exception expected')
except exception.StackValidationFailed as e:
self.assertTrue('could not be found' in e.message.lower())
self.assertTrue('foo' in e.message)
self.assertIn('could not be found', e.message.lower())
self.assertIn('foo', e.message)
@mock.patch.object(resource_chain.ResourceChain, 'create_with_template')
def test_handle_create(self, mock_create):

View File

@ -206,7 +206,7 @@ class SignalTest(common.HeatTestCase):
# Test
first_url = rsrc.FnGetAtt('signal')
self.assertTrue('alarm_url' in first_url)
self.assertIn('alarm_url', first_url)
mock_has.assert_called_once_with('signal_handler')
mock_has.reset_mock() # reset the count for the next check
@ -355,7 +355,7 @@ class SignalTest(common.HeatTestCase):
# Test
first_url = rsrc.FnGetAtt('signal')
self.assertTrue('alarm_url' in first_url)
self.assertIn('alarm_url', first_url)
mock_has.assert_called_once_with('signal_handler')
mock_has.reset_mock() # reset the count for the next check

View File

@ -92,4 +92,4 @@ class EnvironmentMergingTests(functional_base.FunctionalTestsBase):
# by checking to see that it has a value
r3b = self.client.resources.get(stack_id, 'r3b')
r3b_attrs = r3b.attributes
self.assertTrue('value' in r3b_attrs)
self.assertIn('value', r3b_attrs)