From 5b59210ef2b52d56150d6dd3719ed189ad9225ff Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Fri, 15 Jun 2018 12:37:24 +0200 Subject: [PATCH] Fix for python 3 In Python 3, get_reponse returns a bytes object, not str, so we have to encode() and decode(), otherwise it fails. This fixed issues running the tests in Debian. Change-Id: Ifc18bb48e27cee96864e3a9b64d8a4fd294a912b --- .../tests/scenario/test_dashboard_basic_ops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tempest_horizon/tests/scenario/test_dashboard_basic_ops.py b/tempest_horizon/tests/scenario/test_dashboard_basic_ops.py index cd4af56..815b17a 100644 --- a/tempest_horizon/tests/scenario/test_dashboard_basic_ops.py +++ b/tempest_horizon/tests/scenario/test_dashboard_basic_ops.py @@ -84,14 +84,14 @@ class TestDashboardBasicOps(test.BaseTestCase): def check_login_page(self): response = self._get_opener().open(CONF.dashboard.dashboard_url).read() - self.assertIn("id_username", response) + self.assertIn("id_username", response.decode("utf-8")) def user_login(self, username, password): response = self._get_opener().open(CONF.dashboard.dashboard_url).read() # Grab the CSRF token and default region parser = HorizonHTMLParser() - parser.feed(response) + parser.feed(response.decode("utf-8")) # construct login url for dashboard, discovery accommodates non-/ web # root for dashboard @@ -109,11 +109,11 @@ class TestDashboardBasicOps(test.BaseTestCase): 'region': parser.region, 'domain': CONF.auth.default_credentials_domain_name, 'csrfmiddlewaretoken': parser.csrf_token} - self._get_opener().open(req, parse.urlencode(params)) + self._get_opener().open(req, parse.urlencode(params).encode()) def check_home_page(self): response = self._get_opener().open(CONF.dashboard.dashboard_url).read() - self.assertIn('Overview', response) + self.assertIn('Overview', response.decode("utf-8")) def _get_opener(self): if not self.opener: