From 10b46df578f08f54f879d561ccc7d061569fa7b4 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 12 Mar 2018 11:03:11 -0700 Subject: db/utils: decoded_headers will be passed str not bytes I had made the assumption early on that this would get bytes, but when I added `assert isinstance(header, bytes)` alot would crash on startup, changing `bytes` to `str` fixed that. I noticed this when trying to fix the warning generated in the logging call. --- tests/db/utils_test.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/db/utils_test.py b/tests/db/utils_test.py index e3d3596a..b1187fe3 100644 --- a/tests/db/utils_test.py +++ b/tests/db/utils_test.py @@ -248,7 +248,7 @@ class TestDecodeHeader(unittest.TestCase): output = b'=?' + encoding.encode('ascii') + b'?Q?' for byte in string: output += b'=' + codecs.encode(bytes([byte]), 'hex').upper() - return output + b'?=' + return (output + b'?=').decode('ascii') @staticmethod def _base64(unicode_string, encoding): @@ -263,7 +263,7 @@ class TestDecodeHeader(unittest.TestCase): """ string = unicode_string.encode(encoding) b64 = base64.encodebytes(string).strip() - return b'=?' + encoding.encode('utf-8') + b'?B?' + b64 + b'?=' + return (b'=?' + encoding.encode('utf-8') + b'?B?' + b64 + b'?=').decode('ascii') def _test(self, teststring, expected): @@ -306,17 +306,17 @@ class TestDecodeHeader(unittest.TestCase): def test_quoted_words_can_be_interrupted(self): part = u'ÄÖÜäöü' - text = self._base64(part, 'utf-8') + b' and ' + \ + text = self._base64(part, 'utf-8') + ' and ' + \ self._quote(part, 'utf-8') expected = u'ÄÖÜäöü and ÄÖÜäöü' self._test(text, expected) def test_different_encodings_can_be_mixed(self): part = u'ÄÖÜäöü' - 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') + 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') expected = u'utf-8: ÄÖÜäöü again: ÄÖÜäöü latin1: ÄÖÜäöü and ÄÖÜäöü' self._test(text, expected) -- cgit v1.2.3