[merge] make selftest not require something listening on port 25
Marien Zwart
marienz at gentoo.org
Mon Mar 12 03:50:32 GMT 2007
Hi,
Attached is a simple fix to monkeypatch out the bit of smtplib that
connects to port 25 as well as the bit that actually sends mail.
Without this bzr selftest fails with a "connection refused" if there
is nothing listening on port 25.
--
Marien.
-------------- next part --------------
# Bazaar revision bundle v0.9
#
# message:
# Make the merge directive tests work if there is no smtpd running on localhost.
# committer: Marien Zwart <marienz at gentoo.org>
# date: Mon 2007-03-12 04:48:18.862999916 +0100
=== modified file bzrlib/tests/blackbox/test_merge_directive.py
--- bzrlib/tests/blackbox/test_merge_directive.py
+++ bzrlib/tests/blackbox/test_merge_directive.py
@@ -102,15 +102,24 @@
sendmail_calls = []
def sendmail(self, from_, to, message):
sendmail_calls.append((self, from_, to, message))
+ connect_calls = []
+ def connect(self, host='localhost', port=0):
+ connect_calls.append((self, host, port))
old_sendmail = smtplib.SMTP.sendmail
smtplib.SMTP.sendmail = sendmail
+ old_connect = smtplib.SMTP.connect
+ smtplib.SMTP.connect = connect
try:
md_text = self.run_bzr('merge-directive', '--mail-to',
'pqm at example.com', '--plain', '../tree2',
'.')[0]
finally:
smtplib.SMTP.sendmail = old_sendmail
+ smtplib.SMTP.connect = old_connect
self.assertEqual('', md_text)
+ self.assertEqual(1, len(connect_calls))
+ call = connect_calls[0]
+ self.assertEqual(('localhost', 0), call[1:3])
self.assertEqual(1, len(sendmail_calls))
call = sendmail_calls[0]
self.assertEqual(('J. Random Hacker <jrandom at example.com>',
=== modified directory // last-changed:marienz at gentoo.org-20070312034818-vxuap
... tp67gfiv8ym
# revision id: marienz at gentoo.org-20070312034818-vxuaptp67gfiv8ym
# sha1: 34e6a78ad714c555667b70609134ebe738c29af1
# inventory sha1: 9ff1744e3d2ba6967edda2c009ef0b533891ef4e
# parent ids:
# pqm at pqm.ubuntu.com-20070311211206-0fd0176ac1e77ef7
# base id: pqm at pqm.ubuntu.com-20070311211206-0fd0176ac1e77ef7
# properties:
# branch-nick: bzr-mail-test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070312/1bea2d91/attachment.pgp
More information about the bazaar
mailing list