Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2521)

Delta Between Two Patch Sets: Lib/test/test_smtplib.py

Issue 14843: support define_macros / undef_macros in setup.cfg
Left Patch Set: Created 1 year, 1 month ago
Right Patch Set: Created 1 year ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_smtpd.py ('k') | Lib/test/test_subprocess.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 import asyncore 1 import asyncore
2 import email.mime.text 2 import email.mime.text
3 import email.utils 3 import email.utils
4 import socket 4 import socket
5 import smtpd 5 import smtpd
6 import smtplib 6 import smtplib
7 import io 7 import io
8 import re 8 import re
9 import sys 9 import sys
10 import time 10 import time
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 self.assertEqual(smtp.source_address, ('127.0.0.1', port)) 222 self.assertEqual(smtp.source_address, ('127.0.0.1', port))
223 self.assertEqual(smtp.local_hostname, 'localhost') 223 self.assertEqual(smtp.local_hostname, 'localhost')
224 smtp.quit() 224 smtp.quit()
225 except IOError as e: 225 except IOError as e:
226 if e.errno == errno.EADDRINUSE: 226 if e.errno == errno.EADDRINUSE:
227 self.skipTest("couldn't bind to port %d" % port) 227 self.skipTest("couldn't bind to port %d" % port)
228 raise 228 raise
229 229
230 def testNOOP(self): 230 def testNOOP(self):
231 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3) 231 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3)
232 expected = (250, b'OK') 232 expected = (250, b'Ok')
233 self.assertEqual(smtp.noop(), expected) 233 self.assertEqual(smtp.noop(), expected)
234 smtp.quit() 234 smtp.quit()
235 235
236 def testRSET(self): 236 def testRSET(self):
237 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3) 237 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3)
238 expected = (250, b'OK') 238 expected = (250, b'Ok')
239 self.assertEqual(smtp.rset(), expected) 239 self.assertEqual(smtp.rset(), expected)
240 smtp.quit() 240 smtp.quit()
241 241
242 def testNotImplemented(self): 242 def testNotImplemented(self):
243 # EHLO isn't implemented in DebuggingServer 243 # EHLO isn't implemented in DebuggingServer
244 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3) 244 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3)
245 expected = (502, b'Error: command "EHLO" not implemented') 245 expected = (502, b'Error: command "EHLO" not implemented')
246 self.assertEqual(smtp.ehlo(), expected) 246 self.assertEqual(smtp.ehlo(), expected)
247 smtp.quit() 247 smtp.quit()
248 248
249 def testNotImplemented(self):
250 # EXPN isn't implemented in DebuggingServer
251 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3)
252 expected = (502, b'EXPN not implemented')
253 smtp.putcmd('EXPN')
254 self.assertEqual(smtp.getreply(), expected)
255 smtp.quit()
256
257 def testVRFY(self): 249 def testVRFY(self):
258 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3) 250 # VRFY isn't implemented in DebuggingServer
259 expected = (252, b'Cannot VRFY user, but will accept message ' + \ 251 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3)
260 b'and attempt delivery') 252 expected = (502, b'Error: command "VRFY" not implemented')
261 self.assertEqual(smtp.vrfy('nobody@nowhere.com'), expected) 253 self.assertEqual(smtp.vrfy('nobody@nowhere.com'), expected)
262 self.assertEqual(smtp.verify('nobody@nowhere.com'), expected) 254 self.assertEqual(smtp.verify('nobody@nowhere.com'), expected)
263 smtp.quit() 255 smtp.quit()
264 256
265 def testSecondHELO(self): 257 def testSecondHELO(self):
266 # check that a second HELO returns a message that it's a duplicate 258 # check that a second HELO returns a message that it's a duplicate
267 # (this behavior is specific to smtpd.SMTPChannel) 259 # (this behavior is specific to smtpd.SMTPChannel)
268 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3) 260 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3)
269 smtp.helo() 261 smtp.helo()
270 expected = (503, b'Duplicate HELO/EHLO') 262 expected = (503, b'Duplicate HELO/EHLO')
271 self.assertEqual(smtp.helo(), expected) 263 self.assertEqual(smtp.helo(), expected)
272 smtp.quit() 264 smtp.quit()
273 265
274 def testHELP(self): 266 def testHELP(self):
275 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3) 267 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3)
276 self.assertEqual(smtp.help(), b'Supported commands: EHLO HELO MAIL ' + \ 268 self.assertEqual(smtp.help(), b'Error: command "HELP" not implemented')
277 b'RCPT DATA RSET NOOP QUIT VRFY')
278 smtp.quit() 269 smtp.quit()
279 270
280 def testSend(self): 271 def testSend(self):
281 # connect and send mail 272 # connect and send mail
282 m = 'A test message' 273 m = 'A test message'
283 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3) 274 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout =3)
284 smtp.sendmail('John', 'Sally', m) 275 smtp.sendmail('John', 'Sally', m)
285 # XXX(nnorwitz): this test is flaky and dies with a bad file descriptor 276 # XXX(nnorwitz): this test is flaky and dies with a bad file descriptor
286 # in asyncore. This sleep might help, but should really be fixed 277 # in asyncore. This sleep might help, but should really be fixed
287 # properly by using an Event variable. 278 # properly by using an Event variable.
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 814
824 815
825 @support.reap_threads 816 @support.reap_threads
826 def test_main(verbose=None): 817 def test_main(verbose=None):
827 support.run_unittest(GeneralTests, DebuggingServerTests, 818 support.run_unittest(GeneralTests, DebuggingServerTests,
828 NonConnectingTests, 819 NonConnectingTests,
829 BadHELOServerTests, SMTPSimTests) 820 BadHELOServerTests, SMTPSimTests)
830 821
831 if __name__ == '__main__': 822 if __name__ == '__main__':
832 test_main() 823 test_main()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7