diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-02-26 11:04:28 -0800 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2018-03-01 10:34:56 -0800 |
commit | ce076b14bc2c221492f3f80e6d5159d627f0eba0 (patch) | |
tree | 465156a0466aea2bcf706c1567dec57a83a3d91b /tests/db | |
parent | f60afac61959b9fe3bf7412e9a72f0db6b70f3b5 (diff) |
Fix some of the quoted words tests for py3k
Diffstat (limited to 'tests/db')
-rw-r--r-- | tests/db/utils_test.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index c2585813..e3d3596a 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -6,6 +6,7 @@ from __future__ import absolute_import import base64 +import codecs import email import email.header import email.mime.application @@ -244,10 +245,10 @@ class TestDecodeHeader(unittest.TestCase): :rtype: str """ string = unicode_string.encode(encoding) - output = '=?' + encoding + '?Q?' + output = b'=?' + encoding.encode('ascii') + b'?Q?' for byte in string: - output += '=' + byte.encode('hex').upper() - return output + '?=' + output += b'=' + codecs.encode(bytes([byte]), 'hex').upper() + return output + b'?=' @staticmethod def _base64(unicode_string, encoding): @@ -305,17 +306,17 @@ class TestDecodeHeader(unittest.TestCase): def test_quoted_words_can_be_interrupted(self): part = u'ÄÖÜäöü' - text = self._base64(part, 'utf-8') + ' and ' + \ + text = self._base64(part, 'utf-8') + b' and ' + \ self._quote(part, 'utf-8') expected = u'ÄÖÜäöü and ÄÖÜäöü' self._test(text, expected) def test_different_encodings_can_be_mixed(self): part = u'ÄÖÜäöü' - text = 'utf-8: ' + self._base64(part, 'utf-8') + \ - ' again: ' + self._quote(part, 'utf-8') + \ - ' latin1: ' + self._base64(part, 'iso-8859-1') + \ - ' and ' + self._quote(part, 'iso-8859-1') + text = b'utf-8: ' + self._base64(part, 'utf-8') + \ + b' again: ' + self._quote(part, 'utf-8') + \ + b' latin1: ' + self._base64(part, 'iso-8859-1') + \ + b' and ' + self._quote(part, 'iso-8859-1') expected = u'utf-8: ÄÖÜäöü again: ÄÖÜäöü latin1: ÄÖÜäöü and ÄÖÜäöü' self._test(text, expected) |