From f8851fbdd67a66b4acfd4d70bd34fbefef8adc87 Mon Sep 17 00:00:00 2001 From: Cao Xuan Hoang Date: Fri, 9 Dec 2016 09:46:19 +0700 Subject: [PATCH] Use assertGreater(len(x), 0) instead of assertTrue(len(x) > 0) assertGreater provides a nicer error message if it fails. Change-Id: Id9a2e11e21cca87bb4ef23ced5bbbae6817dba73 --- .../dashboards/project/volumes/volumes/tests.py | 4 ++-- .../test/integration_tests/tests/test_defaults.py | 2 +- openstack_dashboard/test/tests/selenium_tests.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py index c0fbf5d3b..a02e32350 100644 --- a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py +++ b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py @@ -1098,8 +1098,8 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase): matching = list(moves.filter(lambda r: _matches_row_id(r), res.context)) - self.assertTrue(len(matching) > 1, - "Expected at least one row matching %s" % row_id) + self.assertGreater(len(matching), 1, + "Expected at least one row matching %s" % row_id) row = matching[-1].dicts[1] matching_actions = list(moves.filter(lambda a: a.name == action_name, row['row_actions'])) diff --git a/openstack_dashboard/test/integration_tests/tests/test_defaults.py b/openstack_dashboard/test/integration_tests/tests/test_defaults.py index 73c717049..9d6e46174 100644 --- a/openstack_dashboard/test/integration_tests/tests/test_defaults.py +++ b/openstack_dashboard/test/integration_tests/tests/test_defaults.py @@ -38,7 +38,7 @@ class TestDefaults(helpers.AdminTestCase): self.assertFalse( self.defaults_page.find_message_and_dismiss(messages.ERROR)) - self.assertTrue(len(default_quota_values) > 0) + self.assertGreater(len(default_quota_values), 0) for quota_name in default_quota_values: self.assertTrue( diff --git a/openstack_dashboard/test/tests/selenium_tests.py b/openstack_dashboard/test/tests/selenium_tests.py index 41932b4e3..c9d787a1f 100644 --- a/openstack_dashboard/test/tests/selenium_tests.py +++ b/openstack_dashboard/test/tests/selenium_tests.py @@ -20,4 +20,4 @@ class BrowserTests(test.SeleniumTestCase): self.selenium.get(self.live_server_url) button = self.selenium.find_element_by_id("loginBtn") # Ensure button has something; must be language independent. - self.assertTrue(len(button.text) > 0) + self.assertGreater(len(button.text), 0)