diff --git a/horizon/test/tests/tables.py b/horizon/test/tests/tables.py index 701c3acbcd..d80fc033f7 100644 --- a/horizon/test/tests/tables.py +++ b/horizon/test/tests/tables.py @@ -1378,7 +1378,7 @@ class DataTableTests(test.TestCase): '', ]) # can_be_selected = False - self.assertTrue(row.get_cells()[0].data == "") + self.assertEqual("", row.get_cells()[0].data) # can_be_selected = True self.assertIn('checkbox', row1.get_cells()[0].data) # status diff --git a/openstack_dashboard/dashboards/project/floating_ips/tests.py b/openstack_dashboard/dashboards/project/floating_ips/tests.py index be2d8a7ce8..fe61c39f3b 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/tests.py +++ b/openstack_dashboard/dashboards/project/floating_ips/tests.py @@ -51,7 +51,7 @@ class FloatingIpViewTests(test.TestCase): workflow = res.context['workflow'] choices = dict(workflow.steps[0].action.fields['ip_id'].choices) # Verify that our "associated" floating IP isn't in the choices list. - self.assertTrue(self.floating_ips.first() not in choices) + self.assertNotIn(self.floating_ips.first(), choices) @test.create_stubs({api.network: ('floating_ip_target_list', 'floating_ip_target_get_by_instance', @@ -74,7 +74,7 @@ class FloatingIpViewTests(test.TestCase): workflow = res.context['workflow'] choices = dict(workflow.steps[0].action.fields['ip_id'].choices) # Verify that our "associated" floating IP isn't in the choices list. - self.assertTrue(self.floating_ips.first() not in choices) + self.assertNotIn(self.floating_ips.first(), choices) @test.create_stubs({api.network: ('floating_ip_target_list', 'tenant_floating_ip_list',)}) @@ -95,7 +95,7 @@ class FloatingIpViewTests(test.TestCase): workflow = res.context['workflow'] choices = dict(workflow.steps[0].action.fields['ip_id'].choices) # Verify that our "associated" floating IP isn't in the choices list. - self.assertTrue(self.floating_ips.first() not in choices) + self.assertNotIn(self.floating_ips.first(), choices) @test.create_stubs({api.network: ('floating_ip_associate', 'floating_ip_target_list', @@ -290,8 +290,8 @@ class FloatingIpViewTests(test.TestCase): allocate_action = self.getAndAssertTableAction(res, 'floating_ips', 'allocate') - self.assertTrue('disabled' in allocate_action.classes, - 'The create button should be disabled') + self.assertIn('disabled', allocate_action.classes, + 'The create button should be disabled') self.assertEqual('Allocate IP To Project (Quota exceeded)', six.text_type(allocate_action.verbose_name)) diff --git a/openstack_dashboard/dashboards/project/images/tests.py b/openstack_dashboard/dashboards/project/images/tests.py index fe0a244e7c..af039d2660 100644 --- a/openstack_dashboard/dashboards/project/images/tests.py +++ b/openstack_dashboard/dashboards/project/images/tests.py @@ -66,8 +66,8 @@ class ImagesAndSnapshotsTests(test.TestCase): self.assertEqual(len(row_actions), 5) row_actions = images_table.get_row_actions(images[1]) self.assertEqual(len(row_actions), 3) - self.assertTrue('delete_image' not in - [a.name for a in row_actions]) + self.assertNotIn('delete_image', + [a.name for a in row_actions]) row_actions = images_table.get_row_actions(images[2]) self.assertEqual(len(row_actions), 4) @@ -416,8 +416,8 @@ class SeleniumTests(test.SeleniumTestCase): copyfrom.send_keys("http://www.test.com/test.iso") formats = self.ui.Select(driver.find_element_by_id("id_disk_format")) body = formats.first_selected_option - self.assertTrue("ISO" in body.text, - "ISO should be selected when the extension is *.iso") + self.assertIn("ISO", body.text, + "ISO should be selected when the extension is *.iso") @unittest.skipIf(os.environ.get('SELENIUM_PHANTOMJS'), "PhantomJS cannot test file upload widgets.") @@ -451,8 +451,8 @@ class SeleniumTests(test.SeleniumTestCase): driver.find_element_by_id("id_image_file").send_keys("/tmp/test.iso") formats = self.ui.Select(driver.find_element_by_id("id_disk_format")) body = formats.first_selected_option - self.assertTrue("ISO" in body.text, - "ISO should be selected when the extension is *.iso") + self.assertIn("ISO", body.text, + "ISO should be selected when the extension is *.iso") @test.create_stubs({api.glance: ('image_list_detailed',)}) def test_create_image_from_url(self): @@ -478,8 +478,8 @@ class SeleniumTests(test.SeleniumTestCase): copyfrom.send_keys("http://www.test.com/test.iso") formats = self.ui.Select(driver.find_element_by_id("id_disk_format")) body = formats.first_selected_option - self.assertTrue("ISO" in body.text, - "ISO should be selected when the extension is *.iso") + self.assertIn("ISO", body.text, + "ISO should be selected when the extension is *.iso") @unittest.skipIf(os.environ.get('SELENIUM_PHANTOMJS'), "PhantomJS cannot test file upload widgets.") @@ -506,5 +506,5 @@ class SeleniumTests(test.SeleniumTestCase): driver.find_element_by_id("id_image_file").send_keys("/tmp/test.iso") formats = self.ui.Select(driver.find_element_by_id("id_disk_format")) body = formats.first_selected_option - self.assertTrue("ISO" in body.text, - "ISO should be selected when the extension is *.iso") + self.assertIn("ISO", body.text, + "ISO should be selected when the extension is *.iso") diff --git a/openstack_dashboard/dashboards/project/instances/tests.py b/openstack_dashboard/dashboards/project/instances/tests.py index 38b6b54c11..1496f5f67d 100644 --- a/openstack_dashboard/dashboards/project/instances/tests.py +++ b/openstack_dashboard/dashboards/project/instances/tests.py @@ -3657,8 +3657,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase): launch_action = self.getAndAssertTableAction( res, 'instances', 'launch-ng') - self.assertTrue('disabled' in launch_action.classes, - 'The launch button should be disabled') + self.assertIn('disabled', launch_action.classes, + 'The launch button should be disabled') self.assertEqual('Launch Instance (Quota exceeded)', six.text_type(launch_action.verbose_name)) diff --git a/openstack_dashboard/test/api_tests/base_tests.py b/openstack_dashboard/test/api_tests/base_tests.py index 7780573df3..8052ccaf13 100644 --- a/openstack_dashboard/test/api_tests/base_tests.py +++ b/openstack_dashboard/test/api_tests/base_tests.py @@ -141,7 +141,7 @@ class APIDictWrapperTests(test.TestCase): msg="Test assumption broken. " "Find new missing attribute.") # We're primarily interested in this test NOT raising a TypeError. - self.assertFalse('missing' in resource) + self.assertNotIn('missing', resource) def test_in_not_there_non_str(self): resource = APIDict.get_instance() @@ -149,7 +149,7 @@ class APIDictWrapperTests(test.TestCase): msg="Test assumption broken. " "Find new missing attribute.") # We're primarily interested in this test NOT raising a TypeError. - self.assertFalse(0 in resource) + self.assertNotIn(0, resource) class ApiVersionTests(test.TestCase): diff --git a/openstack_dashboard/test/api_tests/nova_tests.py b/openstack_dashboard/test/api_tests/nova_tests.py index 315e14826c..5985f8bd56 100644 --- a/openstack_dashboard/test/api_tests/nova_tests.py +++ b/openstack_dashboard/test/api_tests/nova_tests.py @@ -555,7 +555,7 @@ class ComputeApiTests(test.APITestCase): self.assertEqual(flavor.disk, api_flavor.disk) self.assertEqual(0, api_flavor.ephemeral) self.assertEqual(0, api_flavor.swap) - self.assertEqual(True, api_flavor.is_public) + self.assertTrue(api_flavor.is_public) self.assertEqual(1, api_flavor.rxtx_factor) def test_flavor_delete(self): diff --git a/openstack_dashboard/test/api_tests/swift_rest_tests.py b/openstack_dashboard/test/api_tests/swift_rest_tests.py index 839cebc843..46d290ef1b 100644 --- a/openstack_dashboard/test/api_tests/swift_rest_tests.py +++ b/openstack_dashboard/test/api_tests/swift_rest_tests.py @@ -55,7 +55,7 @@ class SwiftRestTestCase(test.TestCase): self.assertStatusCode(response, 200) self.assertEqual(u'container one%\u6346', response.json['items'][0]['name']) - self.assertEqual(False, response.json['has_more']) + self.assertFalse(response.json['has_more']) nc.swift_get_containers.assert_called_once_with(request) # @@ -126,8 +126,8 @@ class SwiftRestTestCase(test.TestCase): self.assertEqual(u'test folder%\u6346/test.txt', response.json['items'][3]['path']) self.assertEqual('test.txt', response.json['items'][3]['name']) - self.assertEqual(True, response.json['items'][3]['is_object']) - self.assertEqual(False, response.json['items'][3]['is_subdir']) + self.assertTrue(response.json['items'][3]['is_object']) + self.assertFalse(response.json['items'][3]['is_subdir']) self.assertEqual(u'test folder%\u6346/test.txt', response.json['items'][3]['path']) @@ -135,8 +135,8 @@ class SwiftRestTestCase(test.TestCase): response.json['items'][4]['path']) self.assertEqual(u'test folder%\u6346', response.json['items'][4]['name']) - self.assertEqual(False, response.json['items'][4]['is_object']) - self.assertEqual(True, response.json['items'][4]['is_subdir']) + self.assertFalse(response.json['items'][4]['is_object']) + self.assertTrue(response.json['items'][4]['is_subdir']) nc.swift_get_objects.assert_called_once_with(request, u'container one%\u6346', @@ -149,8 +149,8 @@ class SwiftRestTestCase(test.TestCase): response = swift.Objects().get(request, u'container one%\u6346') self.assertStatusCode(response, 200) self.assertEqual(1, len(response.json['items'])) - self.assertEqual(True, response.json['items'][0]['is_object']) - self.assertEqual(False, response.json['items'][0]['is_subdir']) + self.assertTrue(response.json['items'][0]['is_object']) + self.assertFalse(response.json['items'][0]['is_subdir']) nc.swift_get_objects.assert_called_once_with( request, u'container one%\u6346', prefix=u'test folder%\u6346/' diff --git a/openstack_dashboard/test/helpers.py b/openstack_dashboard/test/helpers.py index 843c959280..2dc2c4f8cb 100644 --- a/openstack_dashboard/test/helpers.py +++ b/openstack_dashboard/test/helpers.py @@ -321,8 +321,8 @@ class TestCase(horizon_helpers.TestCase): row_actions)) msg_args = (action_name, table_name, row_id) - self.assertTrue( - len(actions) > 0, + self.assertGreater( + len(actions), 0, "No action named '%s' found in '%s' table for id '%s'" % msg_args) self.assertEqual( @@ -339,8 +339,8 @@ class TestCase(horizon_helpers.TestCase): actions = list(moves.filter(lambda x: x.name == action_name, table_actions)) msg_args = (action_name, table_name) - self.assertTrue( - len(actions) > 0, + self.assertGreater( + len(actions), 0, "No action named '%s' found in '%s' table" % msg_args) self.assertEqual( diff --git a/openstack_dashboard/test/integration_tests/tests/test_volumes.py b/openstack_dashboard/test/integration_tests/tests/test_volumes.py index 511b80c6ff..ceb9c63f52 100644 --- a/openstack_dashboard/test/integration_tests/tests/test_volumes.py +++ b/openstack_dashboard/test/integration_tests/tests/test_volumes.py @@ -267,7 +267,7 @@ class TestVolumesActions(helpers.TestCase): self.assertTrue(self.volumes_page.is_volume_status(self.VOLUME_NAME, 'Available')) new_size = self.volumes_page.get_size(self.VOLUME_NAME) - self.assertFalse(orig_size >= new_size) + self.assertLess(orig_size, new_size) @decorators.skip_because(bugs=['1584057']) def test_volume_upload_to_image(self): diff --git a/openstack_dashboard/test/tests/templates.py b/openstack_dashboard/test/tests/templates.py index 73d70aa266..c0d7f20d1d 100644 --- a/openstack_dashboard/test/tests/templates.py +++ b/openstack_dashboard/test/tests/templates.py @@ -37,7 +37,7 @@ class TemplateRenderTest(test.TestCase): context, template.Context(context)) - self.assertFalse("&" in out) + self.assertNotIn("&", out) self.assertIn("ENG Perf R&D", out) def test_openrc_html_evil_shell_escape(self): @@ -65,8 +65,8 @@ class TemplateRenderTest(test.TestCase): context, template.Context(context)) - self.assertFalse('o\"' in out) - self.assertFalse('o"' in out) + self.assertNotIn('o\"', out) + self.assertNotIn('o"', out) self.assertIn('\\"', out) def test_openrc_set_region(self):