Permalink
Browse files

Test Unicode mail subject with all python versions

The previous corrections have fixed Python 3.1 as well.
  • Loading branch information...
1 parent 10e8762 commit ecc892e048491e7e7392eaf44b52f269b88b4a55 @dvarrazzo dvarrazzo committed Dec 5, 2012
Showing with 6 additions and 19 deletions.
  1. +2 −9 logbook/testsuite/test_contextmanager.py
  2. +4 −10 logbook/testsuite/test_regular.py
@@ -271,13 +271,7 @@ def fake_record(message, year, month, day, hour=0,
self.assertEqual(f.readline().rstrip(), '[02:00] Third One')
def test_mail_handler(self):
- # broken in stdlib for 3.1 as far as I can see
- if sys.version_info >= (3, 0) and sys.version_info < (3, 2):
- ascii_subject = True
- subject = u'ascii only'
- else:
- ascii_subject = False
- subject = u'\xf8nicode'
+ subject = u'\xf8nicode'
handler = make_fake_mail_handler(subject=subject)
with capture_stderr() as fallback:
with handler:
@@ -290,8 +284,7 @@ def test_mail_handler(self):
self.assertEqual(len(handler.mails), 1)
sender, receivers, mail = handler.mails[0]
self.assertEqual(sender, handler.from_addr)
- if not ascii_subject:
- self.assert_('=?utf-8?q?=C3=B8nicode?=' in mail)
+ self.assert_('=?utf-8?q?=C3=B8nicode?=' in mail)
self.assert_(re.search('Message type:\s+ERROR', mail))
self.assert_(re.search('Location:.*%s' % test_file, mail))
self.assert_(re.search('Module:\s+%s' % __name__, mail))
@@ -365,13 +365,7 @@ def fake_record(message, year, month, day, hour=0,
f.close()
def test_mail_handler(self):
- # broken in stdlib for 3.1 as far as I can see
- if sys.version_info >= (3, 0) and sys.version_info < (3, 2):
- ascii_subject = True
- subject = u'ascii only'
- else:
- ascii_subject = False
- subject = u'\xf8nicode'
+ subject = u'\xf8nicode'
handler = make_fake_mail_handler(subject=subject)
fallback = capture_stderr.start()
try:
@@ -392,8 +386,7 @@ def test_mail_handler(self):
self.assertEqual(len(handler.mails), 1)
sender, receivers, mail = handler.mails[0]
self.assertEqual(sender, handler.from_addr)
- if not ascii_subject:
- self.assert_('=?utf-8?q?=C3=B8nicode?=' in mail)
+ self.assert_('=?utf-8?q?=C3=B8nicode?=' in mail)
self.assert_(re.search('Message type:\s+ERROR', mail))
self.assert_(re.search('Location:.*%s' % test_file, mail))
self.assert_(re.search('Module:\s+%s' % __name__, mail))
@@ -406,7 +399,7 @@ def test_mail_handler(self):
capture_stderr.end()
def test_mail_handler_unicode(self):
- subject = u'ascii only'
+ subject = u'\xf8nicode'
handler = make_fake_mail_handler(subject=subject)
fallback = capture_stderr.start()
try:
@@ -427,6 +420,7 @@ def test_mail_handler_unicode(self):
self.assertEqual(len(handler.mails), 1)
sender, receivers, mail = handler.mails[0]
self.assertEqual(sender, handler.from_addr)
+ self.assert_('=?utf-8?q?=C3=B8nicode?=' in mail)
self.assert_(re.search('Message type:\s+ERROR', mail))
self.assert_(re.search('Location:.*%s' % test_file, mail))
self.assert_(re.search('Module:\s+%s' % __name__, mail))

0 comments on commit ecc892e

Please sign in to comment.