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
This commit is contained in:
Thomas Goirand 2018-06-15 12:37:24 +02:00
parent a23f4074fd
commit 5b59210ef2
1 changed files with 4 additions and 4 deletions

View File

@ -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: