summaryrefslogtreecommitdiff
path: root/tests/unittests/test_datasource/test_opennebula.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2015-01-26 11:14:06 -0500
committerBarry Warsaw <barry@python.org>2015-01-26 11:14:06 -0500
commit841db73600e3f203243c773109d71ab88d3334bc (patch)
tree051f44833ae1ec1b31c5f893c6eca8b39e07a83c /tests/unittests/test_datasource/test_opennebula.py
parent3246c85763d5cdebb3e240fcd5ae29834cbf6299 (diff)
downloadvyos-cloud-init-841db73600e3f203243c773109d71ab88d3334bc.tar.gz
vyos-cloud-init-841db73600e3f203243c773109d71ab88d3334bc.zip
More test repairs.
Diffstat (limited to 'tests/unittests/test_datasource/test_opennebula.py')
-rw-r--r--tests/unittests/test_datasource/test_opennebula.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py
index b79237f0..1a8d2122 100644
--- a/tests/unittests/test_datasource/test_opennebula.py
+++ b/tests/unittests/test_datasource/test_opennebula.py
@@ -10,6 +10,12 @@ import shutil
import tempfile
import unittest
+def b64(source):
+ # In Python 3, b64encode only accepts bytes and returns bytes.
+ if not isinstance(source, bytes):
+ source = source.encode('utf-8')
+ return b64encode(source).decode('us-ascii')
+
TEST_VARS = {
'VAR1': 'single',
@@ -180,7 +186,7 @@ class TestOpenNebulaDataSource(unittest.TestCase):
self.assertEqual(USER_DATA, results['userdata'])
def test_user_data_encoding_required_for_decode(self):
- b64userdata = b64encode(USER_DATA)
+ b64userdata = b64(USER_DATA)
for k in ('USER_DATA', 'USERDATA'):
my_d = os.path.join(self.tmp, k)
populate_context_dir(my_d, {k: b64userdata})
@@ -192,7 +198,7 @@ class TestOpenNebulaDataSource(unittest.TestCase):
def test_user_data_base64_encoding(self):
for k in ('USER_DATA', 'USERDATA'):
my_d = os.path.join(self.tmp, k)
- populate_context_dir(my_d, {k: b64encode(USER_DATA),
+ populate_context_dir(my_d, {k: b64(USER_DATA),
'USERDATA_ENCODING': 'base64'})
results = ds.read_context_disk_dir(my_d)