summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Watkins <daniel.watkins@canonical.com>2015-03-04 17:20:48 +0000
committerDaniel Watkins <daniel.watkins@canonical.com>2015-03-04 17:20:48 +0000
commit5eb2aab5d010e7b8d5e4146959e50f2a9f67d504 (patch)
tree334f64c4eaadce28ffb0be60eb12fbfbdfdc46dc /tests
parent014468ea3fb36e81a3e5a6fc593ce91571c1495f (diff)
downloadvyos-cloud-init-5eb2aab5d010e7b8d5e4146959e50f2a9f67d504.tar.gz
vyos-cloud-init-5eb2aab5d010e7b8d5e4146959e50f2a9f67d504.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')
-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