~barry/mailman/templatecache

« back to all changes in this revision

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

  • Committer: Barry Warsaw
  • Date: 2012-10-31 16:37:22 UTC
  • mfrom: (7178.1.1 work2)
  • Revision ID: barry@list.org-20121031163722-3lszhsiv9ai0akfp
 * Python 2.7 is not required.  Python 2.6 is no longer officially supported.
   The code base is now also `python2.7 -3` clean, although there are still
   some warnings in 3rd party dependencies.  LP: #1073506

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
    def test_message_id_required(self):
55
55
        # The message is rejected if it does not have a Message-ID header.
56
 
        try:
 
56
        with self.assertRaises(smtplib.SMTPDataError) as cm:
57
57
            self._lmtp.sendmail('anne@example.com', ['test@example.com'], """\
58
58
From: anne@example.com
59
59
To: test@example.com
60
60
Subject: This has no Message-ID header
61
61
 
62
62
""")
63
 
        except smtplib.SMTPDataError as error:
64
 
            pass
65
 
        else:
66
 
            raise AssertionError('SMTPDataError expected')
67
63
        # LMTP returns a 550: Requested action not taken: mailbox unavailable
68
64
        # (e.g., mailbox not found, no access, or command rejected for policy
69
65
        # reasons)
70
 
        self.assertEqual(error.smtp_code, 550)
71
 
        self.assertEqual(error.smtp_error, 'No Message-ID header provided')
 
66
        self.assertEqual(cm.exception.smtp_code, 550)
 
67
        self.assertEqual(cm.exception.smtp_error, 
 
68
                         'No Message-ID header provided')
72
69
 
73
70
    def test_message_id_hash_is_added(self):
74
71
        self._lmtp.sendmail('anne@example.com', ['test@example.com'], """\