summaryrefslogtreecommitdiff
path: root/tests/unittests/test_data.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2015-01-21 17:56:53 -0500
committerBarry Warsaw <barry@python.org>2015-01-21 17:56:53 -0500
commitf895cb12141281702b34da18f2384deb64c881e7 (patch)
tree7a7433752ba1317c370dd3dd815c9ee7331a923b /tests/unittests/test_data.py
parenta64bb4febc79fcf641f6471d8cc00c74ca915f3d (diff)
downloadvyos-cloud-init-f895cb12141281702b34da18f2384deb64c881e7.tar.gz
vyos-cloud-init-f895cb12141281702b34da18f2384deb64c881e7.zip
Largely merge lp:~harlowja/cloud-init/py2-3 albeit manually because it seemed
to be behind trunk. `tox -e py27` passes full test suite. Now to work on replacing mocker.
Diffstat (limited to 'tests/unittests/test_data.py')
-rw-r--r--tests/unittests/test_data.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/unittests/test_data.py b/tests/unittests/test_data.py
index 03296e62..a35afc27 100644
--- a/tests/unittests/test_data.py
+++ b/tests/unittests/test_data.py
@@ -1,11 +1,11 @@
"""Tests for handling of userdata within cloud init."""
-import StringIO
-
import gzip
import logging
import os
+from six import BytesIO, StringIO
+
from email.mime.application import MIMEApplication
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
@@ -53,7 +53,7 @@ class TestConsumeUserData(helpers.FilesystemMockingTestCase):
self.patchUtils(root)
def capture_log(self, lvl=logging.DEBUG):
- log_file = StringIO.StringIO()
+ log_file = StringIO()
self._log_handler = logging.StreamHandler(log_file)
self._log_handler.setLevel(lvl)
self._log = log.getLogger()
@@ -351,9 +351,9 @@ p: 1
"""Tests that individual message gzip encoding works."""
def gzip_part(text):
- contents = StringIO.StringIO()
- f = gzip.GzipFile(fileobj=contents, mode='w')
- f.write(str(text))
+ contents = BytesIO()
+ f = gzip.GzipFile(fileobj=contents, mode='wb')
+ f.write(util.encode_text(text))
f.flush()
f.close()
return MIMEApplication(contents.getvalue(), 'gzip')