Fix Python 3 compatiblity in K8sClient.watch()
This commit fixes classic unicode-bytes incompatibility in K8sClient.watch(). Implements: blueprint goal-python36 Change-Id: I890e0e3541b00bc3ee834feba759ce0d073e94d7 Closes-Bug: 1790902
This commit is contained in:
@@ -197,7 +197,7 @@ class K8sClient(object):
|
|||||||
headers=header)) as response:
|
headers=header)) as response:
|
||||||
if not response.ok:
|
if not response.ok:
|
||||||
raise exc.K8sClientException(response.text)
|
raise exc.K8sClientException(response.text)
|
||||||
for line in response.iter_lines(delimiter='\n'):
|
for line in response.iter_lines():
|
||||||
line = line.strip()
|
line = line.decode('utf-8').strip()
|
||||||
if line:
|
if line:
|
||||||
yield jsonutils.loads(line)
|
yield jsonutils.loads(line)
|
||||||
|
@@ -311,7 +311,7 @@ class TestK8sClient(test_base.TestCase):
|
|||||||
def test_watch(self, m_get):
|
def test_watch(self, m_get):
|
||||||
path = '/test'
|
path = '/test'
|
||||||
data = [{'obj': 'obj%s' % i} for i in range(3)]
|
data = [{'obj': 'obj%s' % i} for i in range(3)]
|
||||||
lines = [jsonutils.dumps(i) for i in data]
|
lines = [jsonutils.dump_as_bytes(i) for i in data]
|
||||||
|
|
||||||
m_resp = mock.MagicMock()
|
m_resp = mock.MagicMock()
|
||||||
m_resp.ok = True
|
m_resp.ok = True
|
||||||
|
Reference in New Issue
Block a user