From b13ec98467f2d374e741efa5888937c5f2b86ebb Mon Sep 17 00:00:00 2001 From: Cedric Brandily Date: Wed, 6 Apr 2016 01:12:40 +0200 Subject: [PATCH] Prefer assertEqual/assertIn over assertOutput/assertInOutput functional.common.tests module defines: * assertOutput (similar to assertEqual) * assertInOutput (similar to assertIn) in order to allow the usage of assertions in testcase classmethods but there is no reason to use them in testcase instancemethods at least because they raise Exception instances instead of AssertionError instances. Change-Id: I9ffcaf9c6e6a1ff5df6ea2d79be3fb4496db4b85 --- functional/tests/common/test_quota.py | 2 +- functional/tests/identity/v2/test_endpoint.py | 2 +- functional/tests/identity/v3/test_endpoint.py | 2 +- functional/tests/identity/v3/test_group.py | 14 +++++++------- functional/tests/identity/v3/test_project.py | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/functional/tests/common/test_quota.py b/functional/tests/common/test_quota.py index 7a0cb64026..62b43a34ab 100644 --- a/functional/tests/common/test_quota.py +++ b/functional/tests/common/test_quota.py @@ -35,4 +35,4 @@ class QuotaTests(test.TestCase): def test_quota_show(self): raw_output = self.openstack('quota show ' + self.PROJECT_NAME) for expected_field in self.EXPECTED_FIELDS: - self.assertInOutput(expected_field, raw_output) + self.assertIn(expected_field, raw_output) diff --git a/functional/tests/identity/v2/test_endpoint.py b/functional/tests/identity/v2/test_endpoint.py index 0aed3220c8..8064365e01 100644 --- a/functional/tests/identity/v2/test_endpoint.py +++ b/functional/tests/identity/v2/test_endpoint.py @@ -27,7 +27,7 @@ class EndpointTests(test_identity.IdentityTests): def test_endpoint_list(self): endpoint_id = self._create_dummy_endpoint() raw_output = self.openstack('endpoint list') - self.assertInOutput(endpoint_id, raw_output) + self.assertIn(endpoint_id, raw_output) items = self.parse_listing(raw_output) self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS) diff --git a/functional/tests/identity/v3/test_endpoint.py b/functional/tests/identity/v3/test_endpoint.py index a7590787d9..e68aa848da 100644 --- a/functional/tests/identity/v3/test_endpoint.py +++ b/functional/tests/identity/v3/test_endpoint.py @@ -31,7 +31,7 @@ class EndpointTests(test_identity.IdentityTests): def test_endpoint_list(self): endpoint_id = self._create_dummy_endpoint() raw_output = self.openstack('endpoint list') - self.assertInOutput(endpoint_id, raw_output) + self.assertIn(endpoint_id, raw_output) items = self.parse_listing(raw_output) self.assert_table_structure(items, self.ENDPOINT_LIST_HEADERS) diff --git a/functional/tests/identity/v3/test_group.py b/functional/tests/identity/v3/test_group.py index 4c6ed19b2d..156a9ff1e8 100644 --- a/functional/tests/identity/v3/test_group.py +++ b/functional/tests/identity/v3/test_group.py @@ -25,7 +25,7 @@ class GroupTests(test_identity.IdentityTests): raw_output = self.openstack('group list') items = self.parse_listing(raw_output) self.assert_table_structure(items, test_identity.BASIC_LIST_HEADERS) - self.assertInOutput(group_name, raw_output) + self.assertIn(group_name, raw_output) def test_group_list_with_domain(self): group_name = self._create_dummy_group() @@ -33,7 +33,7 @@ class GroupTests(test_identity.IdentityTests): 'group list --domain %s' % self.domain_name) items = self.parse_listing(raw_output) self.assert_table_structure(items, test_identity.BASIC_LIST_HEADERS) - self.assertInOutput(group_name, raw_output) + self.assertIn(group_name, raw_output) def test_group_delete(self): group_name = self._create_dummy_group(add_clean_up=False) @@ -102,7 +102,7 @@ class GroupTests(test_identity.IdentityTests): 'user_domain': self.domain_name, 'group': group_name, 'user': username}) - self.assertOutput( + self.assertEqual( '%(user)s added to group %(group)s\n' % {'user': username, 'group': group_name}, raw_output @@ -128,7 +128,7 @@ class GroupTests(test_identity.IdentityTests): 'user_domain': self.domain_name, 'group': group_name, 'user': username}) - self.assertOutput( + self.assertEqual( '%(user)s added to group %(group)s\n' % {'user': username, 'group': group_name}, raw_output @@ -141,7 +141,7 @@ class GroupTests(test_identity.IdentityTests): 'user_domain': self.domain_name, 'group': group_name, 'user': username}) - self.assertOutput( + self.assertEqual( '%(user)s in group %(group)s\n' % {'user': username, 'group': group_name}, raw_output) @@ -165,12 +165,12 @@ class GroupTests(test_identity.IdentityTests): 'user_domain': self.domain_name, 'group': group_name, 'user': username}) - self.assertOutput( + self.assertEqual( '%(user)s added to group %(group)s\n' % {'user': username, 'group': group_name}, add_raw_output ) - self.assertOutput( + self.assertEqual( '%(user)s removed from ' 'group %(group)s\n' % {'user': username, 'group': group_name}, diff --git a/functional/tests/identity/v3/test_project.py b/functional/tests/identity/v3/test_project.py index 204a8d14e4..6c278691f4 100644 --- a/functional/tests/identity/v3/test_project.py +++ b/functional/tests/identity/v3/test_project.py @@ -65,7 +65,7 @@ class ProjectTests(test_identity.IdentityTests): 'project list --domain %s' % self.domain_name) items = self.parse_listing(raw_output) self.assert_table_structure(items, test_identity.BASIC_LIST_HEADERS) - self.assertInOutput(project_name, raw_output) + self.assertIn(project_name, raw_output) self.assertTrue(len(items) > 0) def test_project_set(self):