Replace assertTrue and assertFalse with more suitable asserts

The following replacements were done to have
clearer messages in case of tests failure:
- assertTrue(* in *) with assertIn
- assertFalse(* in *) with assertNotIn

Change-Id: I7cc2ed4365895c430220798de14dc6c5d599e7bd
This commit is contained in:
Sergey Nikitin 2014-05-26 14:33:18 +04:00
parent 8b83737363
commit 0586cc5b46
5 changed files with 11 additions and 11 deletions

View File

@ -95,10 +95,10 @@ class TestAuthPlugin(tests.SQLDriverOverrides, tests.TestCase):
try:
self.api.authenticate({'environment': {}}, auth_info, auth_context)
except exception.AdditionalAuthRequired as e:
self.assertTrue('methods' in e.authentication)
self.assertTrue(METHOD_NAME in e.authentication['methods'])
self.assertTrue(METHOD_NAME in e.authentication)
self.assertTrue('challenge' in e.authentication[METHOD_NAME])
self.assertIn('methods', e.authentication)
self.assertIn(METHOD_NAME, e.authentication['methods'])
self.assertIn(METHOD_NAME, e.authentication)
self.assertIn('challenge', e.authentication[METHOD_NAME])
# test correct response
auth_data = {'methods': [METHOD_NAME]}

View File

@ -186,7 +186,7 @@ class CacheRegionTest(tests.TestCase):
self.assertEqual('test', config_dict['test_prefix.arguments.arg1'])
self.assertEqual('test:test',
config_dict['test_prefix.arguments.arg2'])
self.assertFalse('test_prefix.arguments.arg3' in config_dict)
self.assertNotIn('test_prefix.arguments.arg3', config_dict)
def test_cache_debug_proxy(self):
single_value = 'Test Value'

View File

@ -82,8 +82,8 @@ class V2CatalogTestCase(rest.RestfulTestCase):
def test_endpoint_create(self):
req_body, response = self._endpoint_create()
self.assertTrue('endpoint' in response.result)
self.assertTrue('id' in response.result['endpoint'])
self.assertIn('endpoint', response.result)
self.assertIn('id', response.result['endpoint'])
for field, value in six.iteritems(req_body['endpoint']):
self.assertEqual(response.result['endpoint'][field], value)

View File

@ -870,7 +870,7 @@ class KeystoneClientTests(object):
user=self.user_two['id'],
role=self.role_other['id'])
user_refs = client.tenants.list_users(tenant=self.tenant_bar['id'])
self.assertTrue(self.user_two['id'] in [x.id for x in user_refs])
self.assertIn(self.user_two['id'], [x.id for x in user_refs])
client.roles.remove_user_role(tenant=self.tenant_bar['id'],
user=self.user_two['id'],
role=self.role_other['id'])

View File

@ -135,7 +135,7 @@ class ApplicationTest(BaseWSGITest):
validation = app.has_attributes(resp.body, ['a',
'missing_attribute'])
self.assertFalse(validation[0])
self.assertTrue('missing_attribute' in validation[1])
self.assertIn('missing_attribute', validation[1])
def test_no_required_attributes_present(self):
app = FakeAttributeCheckerApp()
@ -144,8 +144,8 @@ class ApplicationTest(BaseWSGITest):
validation = app.has_attributes(resp.body, ['missing_attribute1',
'missing_attribute2'])
self.assertFalse(validation[0])
self.assertTrue('missing_attribute1' in validation[1])
self.assertTrue('missing_attribute2' in validation[1])
self.assertIn('missing_attribute1', validation[1])
self.assertIn('missing_attribute2', validation[1])
def test_render_response_custom_headers(self):
resp = wsgi.render_response(headers=[('Custom-Header', 'Some-Value')])