changeset 5476:b0048969990d

encoding fixes in test cases
author Christof Meerwald <cmeerw@cmeerw.org>
date Sun, 29 Jul 2018 02:45:39 +0100
parents da22ff1c3501
children b0c2307be3d1
files test/db_test_base.py test/test_mailgw.py
diffstat 2 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/test/db_test_base.py	Sun Jul 29 02:00:24 2018 +0100
+++ b/test/db_test_base.py	Sun Jul 29 02:45:39 2018 +0100
@@ -34,7 +34,7 @@
 from roundup.cgi.templating import HTMLItem
 from roundup.exceptions import UsageError, Reject
 
-from roundup.anypy.strings import u2s
+from roundup.anypy.strings import b2s, s2b, u2s
 
 from .mocknull import MockNull
 
@@ -2588,9 +2588,9 @@
             self.assert_("New submission from admin" in mail_msg)
             self.assert_("one two" in mail_msg)
             self.assert_("File 'test1.txt' not attached" not in mail_msg)
-            self.assert_(base64.encodestring("xxx").rstrip() in mail_msg)
+            self.assert_(b2s(base64.encodestring(s2b("xxx"))).rstrip() in mail_msg)
             self.assert_("File 'test2.txt' not attached" in mail_msg)
-            self.assert_(base64.encodestring("yyy").rstrip() not in mail_msg)
+            self.assert_(b2s(base64.encodestring(s2b("yyy"))).rstrip() not in mail_msg)
         finally :
             roundupdb._ = old_translate_
             Mailer.smtp_send = backup
@@ -2634,9 +2634,9 @@
             self.assert_("New submission from admin" in mail_msg)
             self.assert_("one two" in mail_msg)
             self.assert_("File 'test1.txt' not attached" not in mail_msg)
-            self.assert_(base64.encodestring("xxx").rstrip() in mail_msg)
+            self.assert_(b2s(base64.encodestring(s2b("xxx"))).rstrip() in mail_msg)
             self.assert_("File 'test2.txt' not attached" in mail_msg)
-            self.assert_(base64.encodestring("yyy").rstrip() not in mail_msg)
+            self.assert_(b2s(base64.encodestring(s2b("yyy"))).rstrip() not in mail_msg)
             fp = FeedParser()
             mail_msg = str(res[1]["mail_msg"])
             fp.feed(mail_msg)
@@ -2657,9 +2657,9 @@
             self.assert_("New submission from admin" in mail_msg)
             self.assert_("one two" in mail_msg)
             self.assert_("File 'test1.txt' not attached" not in mail_msg)
-            self.assert_(base64.encodestring("xxx").rstrip() in mail_msg)
+            self.assert_(b2s(base64.encodestring(s2b("xxx"))).rstrip() in mail_msg)
             self.assert_("File 'test2.txt' not attached" in mail_msg)
-            self.assert_(base64.encodestring("yyy").rstrip() not in mail_msg)
+            self.assert_(b2s(base64.encodestring(s2b("yyy"))).rstrip() not in mail_msg)
         finally :
             roundupdb._ = old_translate_
             Mailer.smtp_send = backup
--- a/test/test_mailgw.py	Sun Jul 29 02:00:24 2018 +0100
+++ b/test/test_mailgw.py	Sun Jul 29 02:45:39 2018 +0100
@@ -28,7 +28,7 @@
         reason="Skipping PGP tests: 'pyme' not installed"))
 
 
-from roundup.anypy.strings import StringIO
+from roundup.anypy.strings import StringIO, u2s
 
 if 'SENDMAILDEBUG' not in os.environ:
     os.environ['SENDMAILDEBUG'] = 'mail-test.log'
@@ -2739,8 +2739,7 @@
 
     def testEnc01(self):
         self.db.user.set(self.mary_id,
-            realname='\xe4\xf6\xfc\xc4\xd6\xdc\xdf, Mary'.decode
-            ('latin-1').encode('utf-8'))
+            realname=u2s(u'\xe4\xf6\xfc\xc4\xd6\xdc\xdf, Mary'))
         self.doNewIssue()
         self._handle_mail('''Content-Type: text/plain;
   charset="iso-8859-1"

Roundup Issue Tracker: http://roundup-tracker.org/