diff options
-rw-r--r-- | cloudinit/util.py | 3 | ||||
-rw-r--r-- | tests/unittests/test_cs_util.py | 16 |
2 files changed, 10 insertions, 9 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index c998154a..b845adfd 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -101,6 +101,7 @@ def b64d(source): except UnicodeDecodeError: return decoded + def b64e(source): # Base64 encode some data, accepting bytes or unicode/str, and returning # str/unicode if the result is utf-8 compatible, otherwise returning bytes. @@ -116,7 +117,7 @@ def fully_decoded_payload(part): # bytes, first try to decode to str via CT charset, and failing that, try # utf-8 using surrogate escapes. cte_payload = part.get_payload(decode=True) - if ( six.PY3 and + if (six.PY3 and part.get_content_maintype() == 'text' and isinstance(cte_payload, bytes)): charset = part.get_charset() or 'utf-8' diff --git a/tests/unittests/test_cs_util.py b/tests/unittests/test_cs_util.py index 337ac9a0..d7273035 100644 --- a/tests/unittests/test_cs_util.py +++ b/tests/unittests/test_cs_util.py @@ -47,14 +47,14 @@ class CepkoMock(Cepko): class CepkoResultTests(unittest.TestCase): def setUp(self): pass - ## self.mocked = self.mocker.replace("cloudinit.cs_utils.Cepko", - ## spec=CepkoMock, - ## count=False, - ## passthrough=False) - ## self.mocked() - ## self.mocker.result(CepkoMock()) - ## self.mocker.replay() - ## self.c = Cepko() + # self.mocked = self.mocker.replace("cloudinit.cs_utils.Cepko", + # spec=CepkoMock, + # count=False, + # passthrough=False) + # self.mocked() + # self.mocker.result(CepkoMock()) + # self.mocker.replay() + # self.c = Cepko() def test_getitem(self): result = self.c.all() |