~sambuddhabasu1/mailman/fix_mailman_run_error

« back to all changes in this revision

Viewing changes to src/mailman/runners/tests/test_join.py

  • Committer: Barry Warsaw
  • Date: 2012-03-22 22:29:58 UTC
  • Revision ID: barry@list.org-20120322222958-k1ufc2xivw8cv2d5
Several fixes and cleanups, ostensibly to fix Python 2.6 support.

- email.iterators.body_line_iterator() cannot handle unicodes in Python 2.6,
  because it uses cStringIO.StringIO under the covers, and *that* can't handle
  unicode.  This works fine in Python 2.7, so I override this for the tests
  only under 2.6 (the code itself isn't affected).

- AddressError needs to str() its IAddress attribute explicitly in the
  __str__() method, otherwise under Python 2.6, you'll get unprintable reprs
  in the doctests.  Again, this works correctly in 2.7, but EIBTI, so it can't
  hurt either way.

- EmailError: a new exception, not related to AddressError.  The reason for
  this it to conform to current nomenclature: "address" means an IAddress
  while "email" means a text email address.  So InvalidEmailAddressError
  now derives from EmailError instead of AddressError because it gets passed a
  text email address, and because that is invalid, it never gets turned into
  an IAddress.  The __str__() of this new base exception class does some
  tricky encoding to keep it compatible between Python 2.6 and 2.7.

- UnverifiedAddressError derives from AddressError instead of the more generic
  MailmanError.

- A few random code cleanups are included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
__metaclass__ = type
23
23
__all__ = [
 
24
    'TestJoin',
 
25
    'TestJoinWithDigests',
24
26
    ]
25
27
 
26
28
 
27
29
import unittest
28
30
 
29
 
from email.iterators import body_line_iterator
30
31
from zope.component import getUtility
31
32
 
32
33
from mailman.app.lifecycle import create_list
37
38
from mailman.interfaces.usermanager import IUserManager
38
39
from mailman.runners.command import CommandRunner
39
40
from mailman.testing.helpers import (
 
41
    body_line_iterator,
40
42
    get_queue_messages,
41
43
    make_testable_runner,
42
44
    reset_the_world,