move and rename tests

This commit is contained in:
Nis Martensen 2024-02-19 21:50:51 +01:00
parent 699384fe4d
commit 5ea81fce9e
2 changed files with 31 additions and 29 deletions

View file

@ -158,32 +158,6 @@ def test_debuglevel_2(self):
re.MULTILINE)
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):
@ -308,6 +282,34 @@ def testBasic(self):
# connect
smtp = smtplib.SMTP(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_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()
def testSourceAddress(self):

View file

@ -42,7 +42,7 @@ def test_connect_starttls(self):
server.ehlo()
server.quit()
def test_connect2_starttls(self):
def test_connect_host_port_starttls(self):
support.get_attribute(smtplib, 'SMTP_SSL')
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.check_hostname = False
@ -59,7 +59,7 @@ def test_connect2_starttls(self):
server.ehlo()
server.quit()
def test_connect3_starttls(self):
def test_explicit_connect_starttls(self):
support.get_attribute(smtplib, 'SMTP_SSL')
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.check_hostname = False
@ -77,7 +77,7 @@ def test_connect3_starttls(self):
server.ehlo()
server.quit()
def test_connect4_starttls(self):
def test_explicit_connect_host_port_starttls(self):
support.get_attribute(smtplib, 'SMTP_SSL')
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
context.check_hostname = False