~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_merge_directive.py

  • Committer: Aaron Bentley
  • Date: 2007-06-25 13:17:32 UTC
  • mfrom: (2535.2.5 bzr.smtp_connection)
  • mto: This revision was merged to the branch mainline in revision 2548.
  • Revision ID: abentley@panoramicfeedback.com-20070625131732-8jp7229jrt5r7khp
Add SMTPConnection class (Adeodato Simó)

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
        connect_calls = []
110
110
        def connect(self, host='localhost', port=0):
111
111
            connect_calls.append((self, host, port))
 
112
        def starttls(self):
 
113
            pass
112
114
        old_sendmail = smtplib.SMTP.sendmail
113
115
        smtplib.SMTP.sendmail = sendmail
114
116
        old_connect = smtplib.SMTP.connect
115
117
        smtplib.SMTP.connect = connect
 
118
        old_starttls = smtplib.SMTP.starttls
 
119
        smtplib.SMTP.starttls = starttls
116
120
        try:
117
121
            result = self.run_bzr(*args, **kwargs)
118
122
        finally:
119
123
            smtplib.SMTP.sendmail = old_sendmail
120
124
            smtplib.SMTP.connect = old_connect
 
125
            smtplib.SMTP.starttls = old_starttls
121
126
        return result + (connect_calls, sendmail_calls)
122
127
 
123
128
    def test_mail_default(self):
132
137
        self.assertEqual(('localhost', 0), call[1:3])
133
138
        self.assertEqual(1, len(sendmail_calls))
134
139
        call = sendmail_calls[0]
135
 
        self.assertEqual(('J. Random Hacker <jrandom@example.com>',
136
 
                          'pqm@example.com'), call[1:3])
 
140
        self.assertEqual(('jrandom@example.com', ['pqm@example.com']),
 
141
                call[1:3])
137
142
        self.assertContainsRe(call[3], EMAIL1)
138
143
 
139
144
    def test_pull_raw(self):