From bc5d12f3d037f44d02a155254bcb10540126429d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 28 Aug 2015 16:49:15 +0200 Subject: [PATCH] Port config_rest_tests to Python 3 * ConfigRestTestCase: remove assertContains and assertNotContains methods, reuse assertIn and assertNotIn instead. * Fix also the HTTP body type is byte string. * tox.ini: add config_rest_tests to Python 3.4 Partial-Implements: blueprint porting-python3 Change-Id: I8cd28b4ed13ea07d77ff4c33d37162d8bf89a3a6 --- .../test/api_tests/config_rest_tests.py | 18 +++--------------- tox.ini | 1 + 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/openstack_dashboard/test/api_tests/config_rest_tests.py b/openstack_dashboard/test/api_tests/config_rest_tests.py index b9747ae490..0dd05c447f 100644 --- a/openstack_dashboard/test/api_tests/config_rest_tests.py +++ b/openstack_dashboard/test/api_tests/config_rest_tests.py @@ -17,22 +17,10 @@ from openstack_dashboard.test import helpers as test class ConfigRestTestCase(test.TestCase): - def assertContains(self, response, expected_content): - if response.find(expected_content) > 0: - return - self.fail('%s does not contain %s' % - (response, expected_content)) - - def assertNotContains(self, response, expected_content): - if response.find(expected_content) < 0: - return - self.fail('%s contains %s when it should not' % - (response, expected_content)) - def test_settings_config_get(self): request = self.mock_rest_request() response = config.Settings().get(request) self.assertStatusCode(response, 200) - self.assertContains(response.content, "REST_API_SETTING_1") - self.assertContains(response.content, "REST_API_SETTING_2") - self.assertNotContains(response.content, "REST_API_SECURITY") + self.assertIn(b"REST_API_SETTING_1", response.content) + self.assertIn(b"REST_API_SETTING_2", response.content) + self.assertNotIn(b"REST_API_SECURITY", response.content) diff --git a/tox.ini b/tox.ini index 5bb1c115e3..d68ee5cdd6 100644 --- a/tox.ini +++ b/tox.ini @@ -46,6 +46,7 @@ commands = openstack_dashboard.test.api_tests.base_tests.QuotaSetTests \ openstack_dashboard.test.api_tests.ceilometer_tests \ openstack_dashboard.test.api_tests.cinder_tests \ + openstack_dashboard.test.api_tests.config_rest_tests \ openstack_dashboard.test.api_tests.fwaas_tests \ openstack_dashboard.test.api_tests.keystone_tests \ openstack_dashboard.test.api_tests.lbaas_tests \