[Python-checkins] r73025 - in python/branches/release30-maint: Lib/test/test_smtplib.py
r.david.murray
python-checkins at python.org
Fri May 29 20:06:14 CEST 2009
Author: r.david.murray
Date: Fri May 29 20:06:14 2009
New Revision: 73025
Log:
Merged revisions 73024 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r73024 | r.david.murray | 2009-05-29 14:03:16 -0400 (Fri, 29 May 2009) | 9 lines
Merged revisions 73022 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r73022 | r.david.murray | 2009-05-29 13:31:05 -0400 (Fri, 29 May 2009) | 2 lines
Refactor test parameterization to resolve update timing problem.
........
................
Modified:
python/branches/release30-maint/ (props changed)
python/branches/release30-maint/Lib/test/test_smtplib.py
Modified: python/branches/release30-maint/Lib/test/test_smtplib.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_smtplib.py (original)
+++ python/branches/release30-maint/Lib/test/test_smtplib.py Fri May 29 20:06:14 2009
@@ -302,17 +302,11 @@
# Simulated SMTP channel & server
class SimSMTPChannel(smtpd.SMTPChannel):
- def __init__(self, *args, **kw):
- self.__extrafeatures = []
+ def __init__(self, extra_features, *args, **kw):
+ self._extrafeatures = ''.join(
+ [ "250-{0}\r\n".format(x) for x in extra_features ])
super(SimSMTPChannel, self).__init__(*args, **kw)
- @property
- def _extrafeatures(self):
- return ''.join([ "250-{0}\r\n".format(x) for x in self.__extrafeatures ])
-
- def add_feature(self, feature):
- self.__extrafeatures.append(feature)
-
def smtp_EHLO(self, arg):
resp = ('250-testhost\r\n'
'250-EXPN\r\n'
@@ -362,15 +356,20 @@
class SimSMTPServer(smtpd.SMTPServer):
+ def __init__(self, *args, **kw):
+ self._extra_features = []
+ smtpd.SMTPServer.__init__(self, *args, **kw)
+
def handle_accept(self):
conn, addr = self.accept()
- self._SMTPchannel = SimSMTPChannel(self, conn, addr)
+ self._SMTPchannel = SimSMTPChannel(self._extra_features,
+ self, conn, addr)
def process_message(self, peer, mailfrom, rcpttos, data):
pass
def add_feature(self, feature):
- self._SMTPchannel.add_feature(feature)
+ self._extra_features.append(feature)
# Test various SMTP & ESMTP commands/behaviors that require a simulated server
@@ -452,8 +451,8 @@
smtp.quit()
def testAUTH_PLAIN(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
self.serv.add_feature("AUTH PLAIN")
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
expected_auth_ok = (235, b'plain auth ok')
self.assertEqual(smtp.login(sim_auth[0], sim_auth[1]), expected_auth_ok)
@@ -467,16 +466,16 @@
# the error message).
def testAUTH_LOGIN(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
self.serv.add_feature("AUTH LOGIN")
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
try: smtp.login(sim_auth[0], sim_auth[1])
except smtplib.SMTPAuthenticationError as err:
if sim_auth_login_password not in str(err):
raise "expected encoded password not found in error message"
def testAUTH_CRAM_MD5(self):
- smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
self.serv.add_feature("AUTH CRAM-MD5")
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
try: smtp.login(sim_auth[0], sim_auth[1])
except smtplib.SMTPAuthenticationError as err:
More information about the Python-checkins
mailing list