Update "data" to bytes object

The param "data" in  f.write(data) should be bytes.

Change-Id: Icbf9463c6f406df9cf25a8cf637b0173387582c5
This commit is contained in:
Caihui 2020-06-30 04:49:23 -07:00
parent 19aae78daf
commit 58cb979a40

View File

@ -14,7 +14,6 @@
import os
import shutil
import sys
import tempfile
import unittest
from unittest import mock
@ -44,8 +43,6 @@ class TestUtils(unittest.TestCase):
temp.close()
self.assertFalse(os.path.exists(temp.name))
# @unittest.skipIf(sys.version_info.major == 3,
# 'Not supported on python v 3.x')
def test_find_config_files_path(self):
temp = tempfile.NamedTemporaryFile('wb', delete=True,
suffix='.conf')
@ -55,12 +52,10 @@ class TestUtils(unittest.TestCase):
temp.close()
self.assertFalse(os.path.exists(temp.name))
@unittest.skipIf(sys.version_info.major == 3,
'Not supported on python v 3.x')
def test_get_jobs_from_disk(self):
temp = tempfile.mkdtemp()
file = '/'.join([temp, "test.conf"])
data = '{"job_id": "test"}'
data = b'{"job_id": "test"}'
with open(file, 'wb') as f:
f.write(data)
ret = utils.get_jobs_from_disk(temp)