From cf213fc69c1c1e94b4abcc1ab26870464ba564f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Cardona?= Date: Fri, 18 Sep 2015 15:45:46 +0200 Subject: [umessage] Work around bug in python 3's decode_header We sometimes get unicode objects out of that function, on which .decode() obviously fails. Upstream has apparently not to fix the existing function, so let's handle it ourselves. Tests are taken from CubicWeb. Related to #1716128. --- test/unittest_umessage.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/unittest_umessage.py b/test/unittest_umessage.py index 531573c..940b308 100644 --- a/test/unittest_umessage.py +++ b/test/unittest_umessage.py @@ -60,6 +60,18 @@ class UMessageTC(TestCase): self.assertEqual(type(test), text_type) self.assertEqual(test, u'Raphaël DUPONT') + def test_decode_QP_utf8(self): + test_line = '=?utf-8?q?o=C3=AEm?= ' + test = decode_QP(test_line) + self.assertEqual(type(test), text_type) + self.assertEqual(test, u'oîm ') + + def test_decode_QP_ascii(self): + test_line = 'test ' + test = decode_QP(test_line) + self.assertEqual(type(test), text_type) + self.assertEqual(test, u'test ') + if __name__ == '__main__': unittest_main() -- cgit v1.2.1