summaryrefslogtreecommitdiff
path: root/tests/unittests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2015-03-04 17:09:32 -0500
committerScott Moser <smoser@ubuntu.com>2015-03-04 17:09:32 -0500
commit56a594cb47342b89629e0876bd63b4e724d5e1a2 (patch)
tree787e72e1bba979810aa998eeab6eade13fbd06a4 /tests/unittests
parent068ee3d324350fd998e2a27e5be2991ea9bab52f (diff)
parent5eb2aab5d010e7b8d5e4146959e50f2a9f67d504 (diff)
downloadvyos-cloud-init-56a594cb47342b89629e0876bd63b4e724d5e1a2.tar.gz
vyos-cloud-init-56a594cb47342b89629e0876bd63b4e724d5e1a2.zip
Add util.message_from_string to wrap email.message_from_string.
This is to work-around the fact that email.message_from_string uses cStringIO in Python 2.6, which can't handle Unicode.
Diffstat (limited to 'tests/unittests')
-rw-r--r--tests/unittests/test_util.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index 7da1f755..1619b5d2 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -452,4 +452,11 @@ class TestMultiLog(helpers.FilesystemMockingTestCase):
util.multi_log('message', log=log, log_level=log_level)
self.assertEqual((log_level, mock.ANY), log.log.call_args[0])
+
+class TestMessageFromString(helpers.TestCase):
+
+ def test_unicode_not_messed_up(self):
+ roundtripped = util.message_from_string(u'\n').as_string()
+ self.assertNotIn('\x00', roundtripped)
+
# vi: ts=4 expandtab