Skip to content

Commit 5ea81fc

Browse files
committed
move and rename tests
1 parent 699384f commit 5ea81fc

File tree

2 files changed

+31
-29
lines changed

2 files changed

+31
-29
lines changed

Lib/test/test_smtplib.py

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -158,32 +158,6 @@ def test_debuglevel_2(self):
158158
re.MULTILINE)
159159
self.assertRegex(stderr.getvalue(), expected)
160160

161-
def test_host_port_host(self):
162-
mock_socket.reply_with(b"220 Hello world")
163-
# create instance without arguments
164-
smtp = smtplib.SMTP(f"{HOST}:{self.port}")
165-
# .connect must set ._host since it is used by .starttls
166-
self.assertEqual(smtp._host, HOST)
167-
smtp.close()
168-
169-
def test_explicit_connect(self):
170-
mock_socket.reply_with(b"220 Hello world")
171-
# create instance without arguments
172-
smtp = smtplib.SMTP()
173-
# .connect must set ._host since it is used by .starttls
174-
smtp.connect(HOST, self.port)
175-
self.assertEqual(smtp._host, HOST)
176-
smtp.close()
177-
178-
def test_explicit_connect_host_port(self):
179-
mock_socket.reply_with(b"220 Hello world")
180-
# create instance without arguments
181-
smtp = smtplib.SMTP()
182-
# .connect must set ._host since it is used by .starttls
183-
smtp.connect(f"{HOST}:{self.port}")
184-
self.assertEqual(smtp._host, HOST)
185-
smtp.close()
186-
187161

188162
class SMTPGeneralTests(GeneralTests, unittest.TestCase):
189163

@@ -308,6 +282,34 @@ def testBasic(self):
308282
# connect
309283
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
310284
timeout=support.LOOPBACK_TIMEOUT)
285+
# implicit .connect must set ._host since it is used by .starttls
286+
self.assertEqual(smtp._host, HOST)
287+
smtp.quit()
288+
289+
def test_host_port_host(self):
290+
# create instance with host:port notation
291+
smtp = smtplib.SMTP(f"{HOST}:{self.port}", local_hostname='localhost',
292+
timeout=support.LOOPBACK_TIMEOUT)
293+
# implicit .connect must set ._host since it is used by .starttls
294+
self.assertEqual(smtp._host, HOST)
295+
smtp.quit()
296+
297+
def test_explicit_connect(self):
298+
# create instance without arguments
299+
smtp = smtplib.SMTP(local_hostname='localhost',
300+
timeout=support.LOOPBACK_TIMEOUT)
301+
# explicit .connect must set ._host since it is used by .starttls
302+
smtp.connect(HOST, self.port)
303+
self.assertEqual(smtp._host, HOST)
304+
smtp.quit()
305+
306+
def test_explicit_connect_host_port(self):
307+
# create instance without arguments
308+
smtp = smtplib.SMTP(local_hostname='localhost',
309+
timeout=support.LOOPBACK_TIMEOUT)
310+
# explicit .connect with host:port notation must set ._host, too
311+
smtp.connect(f"{HOST}:{self.port}")
312+
self.assertEqual(smtp._host, HOST)
311313
smtp.quit()
312314

313315
def testSourceAddress(self):

Lib/test/test_smtpnet.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_connect_starttls(self):
4242
server.ehlo()
4343
server.quit()
4444

45-
def test_connect2_starttls(self):
45+
def test_connect_host_port_starttls(self):
4646
support.get_attribute(smtplib, 'SMTP_SSL')
4747
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
4848
context.check_hostname = False
@@ -59,7 +59,7 @@ def test_connect2_starttls(self):
5959
server.ehlo()
6060
server.quit()
6161

62-
def test_connect3_starttls(self):
62+
def test_explicit_connect_starttls(self):
6363
support.get_attribute(smtplib, 'SMTP_SSL')
6464
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
6565
context.check_hostname = False
@@ -77,7 +77,7 @@ def test_connect3_starttls(self):
7777
server.ehlo()
7878
server.quit()
7979

80-
def test_connect4_starttls(self):
80+
def test_explicit_connect_host_port_starttls(self):
8181
support.get_attribute(smtplib, 'SMTP_SSL')
8282
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
8383
context.check_hostname = False

0 commit comments

Comments
 (0)