diff options
| author | Luong Anh Tuan <tuanla@vn.fujitsu.com> | 2016-12-15 13:21:53 +0700 |
|---|---|---|
| committer | Tuan Luong-Anh <tuanla@vn.fujitsu.com> | 2016-12-16 04:29:16 +0000 |
| commit | 81780adef861d7a2be6b198589cecc059f0d01a7 (patch) | |
| tree | 0b14eec7e54b3ec3e510a65aa7bc347b4860e8e1 /ironic_python_agent/tests/unit | |
| parent | 28da1ca05a45887e659bf92192efc8a9b7f6fe17 (diff) | |
| download | ironic-python-agent-81780adef861d7a2be6b198589cecc059f0d01a7.tar.gz | |
Use oslo_serialization.base64 to follow OpenStack Python3
This patch replaces python standard base64 library call to
oslo_serialization.base64 to follow OpenStack Python3 porting
standard [1].
Use base64 encoding takes 8-bit binary byte data and encodes it. On
Python3, A string is a sequence of Unicode characters thus base64 has
no idea what to do with Unicode data, it's not 8-bit[2]. We use
oslo_serialization.base64 for both python2 and python3.
[1] https://wiki.openstack.org/wiki/Python3
[2] http://stackoverflow.com/questions/8908287/base64-encoding-in-python-3
Change-Id: I1dafe878a71f37d223eaf58ea8e2e8c6b4422a14
Diffstat (limited to 'ironic_python_agent/tests/unit')
| -rw-r--r-- | ironic_python_agent/tests/unit/test_utils.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ironic_python_agent/tests/unit/test_utils.py b/ironic_python_agent/tests/unit/test_utils.py index ebfd3071..487e6aee 100644 --- a/ironic_python_agent/tests/unit/test_utils.py +++ b/ironic_python_agent/tests/unit/test_utils.py @@ -13,7 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -import base64 import errno import glob import io @@ -27,6 +26,7 @@ import testtools from ironic_lib import utils as ironic_utils import mock from oslo_concurrency import processutils +from oslo_serialization import base64 from oslotest import base as test_base from ironic_python_agent import errors @@ -386,7 +386,7 @@ class TestUtils(testtools.TestCase): io_dict = {'fake-name': io.BytesIO(bytes(contents))} data = utils.gzip_and_b64encode(io_dict=io_dict) - res = io.BytesIO(base64.b64decode(data)) + res = io.BytesIO(base64.decode_as_bytes(data)) with tarfile.open(fileobj=res) as tar: members = [(m.name, m.size) for m in tar] self.assertEqual([('fake-name', len(contents))], members) |
