[Python-checkins] r83714 - in python/branches/py3k/Lib/test: mock_socket.py test_smtpd.py test_smtplib.py
richard.jones
python-checkins at python.org
Wed Aug 4 14:27:36 CEST 2010
Author: richard.jones
Date: Wed Aug 4 14:27:36 2010
New Revision: 83714
Log:
fix test_smtplib/test_smtpd collision through pre-loaded reply data in mock_socket
Modified:
python/branches/py3k/Lib/test/mock_socket.py
python/branches/py3k/Lib/test/test_smtpd.py
python/branches/py3k/Lib/test/test_smtplib.py
Modified: python/branches/py3k/Lib/test/mock_socket.py
==============================================================================
--- python/branches/py3k/Lib/test/mock_socket.py (original)
+++ python/branches/py3k/Lib/test/mock_socket.py Wed Aug 4 14:27:36 2010
@@ -36,6 +36,7 @@
self.lines = []
if _reply_data:
self.lines.append(_reply_data)
+ _reply_data = None
self.conn = None
self.timeout = None
Modified: python/branches/py3k/Lib/test/test_smtpd.py
==============================================================================
--- python/branches/py3k/Lib/test/test_smtpd.py (original)
+++ python/branches/py3k/Lib/test/test_smtpd.py Wed Aug 4 14:27:36 2010
@@ -189,8 +189,8 @@
self.write_line(b'RCPT To:ham at example')
self.write_line(b'DATA')
self.write_line(b'data\r\n.')
- self.assertEqual(self.server.messages[-1],
- ('peer', 'eggs at example', ['spam at example','ham at example'], 'data'))
+ self.assertEqual(self.server.messages,
+ [('peer', 'eggs at example', ['spam at example','ham at example'], 'data')])
def test_manual_status(self):
# checks that the Channel is able to return a custom status message
@@ -209,8 +209,8 @@
self.write_line(b'RCPT To:eggs at example')
self.write_line(b'DATA')
self.write_line(b'data\r\n.')
- self.assertEqual(self.server.messages[0],
- ('peer', 'foo at example', ['eggs at example'], 'data'))
+ self.assertEqual(self.server.messages,
+ [('peer', 'foo at example', ['eggs at example'], 'data')])
def test_RSET_syntax(self):
self.write_line(b'RSET hi')
Modified: python/branches/py3k/Lib/test/test_smtplib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_smtplib.py (original)
+++ python/branches/py3k/Lib/test/test_smtplib.py Wed Aug 4 14:27:36 2010
@@ -64,17 +64,20 @@
smtp.close()
def testBasic2(self):
+ mock_socket.reply_with(b"220 Hola mundo")
# connects, include port in host name
smtp = smtplib.SMTP("%s:%s" % (HOST, self.port))
smtp.close()
def testLocalHostName(self):
+ mock_socket.reply_with(b"220 Hola mundo")
# check that supplied local_hostname is used
smtp = smtplib.SMTP(HOST, self.port, local_hostname="testhost")
self.assertEqual(smtp.local_hostname, "testhost")
smtp.close()
def testTimeoutDefault(self):
+ mock_socket.reply_with(b"220 Hola mundo")
self.assertTrue(mock_socket.getdefaulttimeout() is None)
mock_socket.setdefaulttimeout(30)
self.assertEqual(mock_socket.getdefaulttimeout(), 30)
@@ -86,6 +89,7 @@
smtp.close()
def testTimeoutNone(self):
+ mock_socket.reply_with(b"220 Hola mundo")
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
@@ -96,6 +100,7 @@
smtp.close()
def testTimeoutValue(self):
+ mock_socket.reply_with(b"220 Hola mundo")
smtp = smtplib.SMTP(HOST, self.port, timeout=30)
self.assertEqual(smtp.sock.gettimeout(), 30)
smtp.close()
More information about the Python-checkins
mailing list