Skip to content

Commit 8e36cb7

Browse files
diegorussoambv
andauthored
Test: Get the smtp test server using os.getenv() (#117979)
The smtp test server can be set via CPYTHON_TEST_SMTP_SERVER environment variable. If not set, it uses the default value smtp.gmail.com This is needed because the network I'm on filters access to smtp.gmail.com resulting in a failing test. Co-authored-by: Łukasz Langa <[email protected]>
1 parent 75eed5b commit 8e36cb7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/test/test_smtpnet.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
from test import support
33
from test.support import import_helper
44
from test.support import socket_helper
5+
import os
56
import smtplib
67
import socket
78

89
ssl = import_helper.import_module("ssl")
910

1011
support.requires("network")
1112

13+
SMTP_TEST_SERVER = os.getenv('CPYTHON_TEST_SMTP_SERVER', 'smtp.gmail.com')
14+
1215
def check_ssl_verifiy(host, port):
1316
context = ssl.create_default_context()
1417
with socket.create_connection((host, port)) as sock:
@@ -22,7 +25,7 @@ def check_ssl_verifiy(host, port):
2225

2326

2427
class SmtpTest(unittest.TestCase):
25-
testServer = 'smtp.gmail.com'
28+
testServer = SMTP_TEST_SERVER
2629
remotePort = 587
2730

2831
def test_connect_starttls(self):
@@ -44,7 +47,7 @@ def test_connect_starttls(self):
4447

4548

4649
class SmtpSSLTest(unittest.TestCase):
47-
testServer = 'smtp.gmail.com'
50+
testServer = SMTP_TEST_SERVER
4851
remotePort = 465
4952

5053
def test_connect(self):

0 commit comments

Comments
 (0)