Skip to content

Commit

Permalink
Test Unicode mail subject with all python versions
Browse files Browse the repository at this point in the history
The previous corrections have fixed Python 3.1 as well.
  • Loading branch information
dvarrazzo committed Dec 5, 2012
1 parent 10e8762 commit ecc892e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
11 changes: 2 additions & 9 deletions logbook/testsuite/test_contextmanager.py
Expand Up @@ -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:
Expand All @@ -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))
Expand Down
14 changes: 4 additions & 10 deletions logbook/testsuite/test_regular.py
Expand Up @@ -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:
Expand All @@ -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))
Expand All @@ -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:
Expand All @@ -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))
Expand Down

0 comments on commit ecc892e

Please sign in to comment.