mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
move and rename tests
This commit is contained in:
parent
699384fe4d
commit
5ea81fce9e
2 changed files with 31 additions and 29 deletions
|
|
@ -158,32 +158,6 @@ def test_debuglevel_2(self):
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
self.assertRegex(stderr.getvalue(), expected)
|
self.assertRegex(stderr.getvalue(), expected)
|
||||||
|
|
||||||
def test_host_port_host(self):
|
|
||||||
mock_socket.reply_with(b"220 Hello world")
|
|
||||||
# create instance without arguments
|
|
||||||
smtp = smtplib.SMTP(f"{HOST}:{self.port}")
|
|
||||||
# .connect must set ._host since it is used by .starttls
|
|
||||||
self.assertEqual(smtp._host, HOST)
|
|
||||||
smtp.close()
|
|
||||||
|
|
||||||
def test_explicit_connect(self):
|
|
||||||
mock_socket.reply_with(b"220 Hello world")
|
|
||||||
# create instance without arguments
|
|
||||||
smtp = smtplib.SMTP()
|
|
||||||
# .connect must set ._host since it is used by .starttls
|
|
||||||
smtp.connect(HOST, self.port)
|
|
||||||
self.assertEqual(smtp._host, HOST)
|
|
||||||
smtp.close()
|
|
||||||
|
|
||||||
def test_explicit_connect_host_port(self):
|
|
||||||
mock_socket.reply_with(b"220 Hello world")
|
|
||||||
# create instance without arguments
|
|
||||||
smtp = smtplib.SMTP()
|
|
||||||
# .connect must set ._host since it is used by .starttls
|
|
||||||
smtp.connect(f"{HOST}:{self.port}")
|
|
||||||
self.assertEqual(smtp._host, HOST)
|
|
||||||
smtp.close()
|
|
||||||
|
|
||||||
|
|
||||||
class SMTPGeneralTests(GeneralTests, unittest.TestCase):
|
class SMTPGeneralTests(GeneralTests, unittest.TestCase):
|
||||||
|
|
||||||
|
|
@ -308,6 +282,34 @@ def testBasic(self):
|
||||||
# connect
|
# connect
|
||||||
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
|
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
|
||||||
timeout=support.LOOPBACK_TIMEOUT)
|
timeout=support.LOOPBACK_TIMEOUT)
|
||||||
|
# implicit .connect must set ._host since it is used by .starttls
|
||||||
|
self.assertEqual(smtp._host, HOST)
|
||||||
|
smtp.quit()
|
||||||
|
|
||||||
|
def test_host_port_host(self):
|
||||||
|
# create instance with host:port notation
|
||||||
|
smtp = smtplib.SMTP(f"{HOST}:{self.port}", local_hostname='localhost',
|
||||||
|
timeout=support.LOOPBACK_TIMEOUT)
|
||||||
|
# implicit .connect must set ._host since it is used by .starttls
|
||||||
|
self.assertEqual(smtp._host, HOST)
|
||||||
|
smtp.quit()
|
||||||
|
|
||||||
|
def test_explicit_connect(self):
|
||||||
|
# create instance without arguments
|
||||||
|
smtp = smtplib.SMTP(local_hostname='localhost',
|
||||||
|
timeout=support.LOOPBACK_TIMEOUT)
|
||||||
|
# explicit .connect must set ._host since it is used by .starttls
|
||||||
|
smtp.connect(HOST, self.port)
|
||||||
|
self.assertEqual(smtp._host, HOST)
|
||||||
|
smtp.quit()
|
||||||
|
|
||||||
|
def test_explicit_connect_host_port(self):
|
||||||
|
# create instance without arguments
|
||||||
|
smtp = smtplib.SMTP(local_hostname='localhost',
|
||||||
|
timeout=support.LOOPBACK_TIMEOUT)
|
||||||
|
# explicit .connect with host:port notation must set ._host, too
|
||||||
|
smtp.connect(f"{HOST}:{self.port}")
|
||||||
|
self.assertEqual(smtp._host, HOST)
|
||||||
smtp.quit()
|
smtp.quit()
|
||||||
|
|
||||||
def testSourceAddress(self):
|
def testSourceAddress(self):
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ def test_connect_starttls(self):
|
||||||
server.ehlo()
|
server.ehlo()
|
||||||
server.quit()
|
server.quit()
|
||||||
|
|
||||||
def test_connect2_starttls(self):
|
def test_connect_host_port_starttls(self):
|
||||||
support.get_attribute(smtplib, 'SMTP_SSL')
|
support.get_attribute(smtplib, 'SMTP_SSL')
|
||||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||||
context.check_hostname = False
|
context.check_hostname = False
|
||||||
|
|
@ -59,7 +59,7 @@ def test_connect2_starttls(self):
|
||||||
server.ehlo()
|
server.ehlo()
|
||||||
server.quit()
|
server.quit()
|
||||||
|
|
||||||
def test_connect3_starttls(self):
|
def test_explicit_connect_starttls(self):
|
||||||
support.get_attribute(smtplib, 'SMTP_SSL')
|
support.get_attribute(smtplib, 'SMTP_SSL')
|
||||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||||
context.check_hostname = False
|
context.check_hostname = False
|
||||||
|
|
@ -77,7 +77,7 @@ def test_connect3_starttls(self):
|
||||||
server.ehlo()
|
server.ehlo()
|
||||||
server.quit()
|
server.quit()
|
||||||
|
|
||||||
def test_connect4_starttls(self):
|
def test_explicit_connect_host_port_starttls(self):
|
||||||
support.get_attribute(smtplib, 'SMTP_SSL')
|
support.get_attribute(smtplib, 'SMTP_SSL')
|
||||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||||
context.check_hostname = False
|
context.check_hostname = False
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue