From dd99b6db9c7f43b25f0968181af5d20f7032bc8b Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Mon, 15 Apr 2024 22:05:44 +0100 Subject: [PATCH 1/2] Get the smtp test server using os.getenv() The smtp test server can be set via SMTP_TEST_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. --- Lib/test/test_smtpnet.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_smtpnet.py b/Lib/test/test_smtpnet.py index 2e0dc1aa276f35..fd98daaafb0667 100644 --- a/Lib/test/test_smtpnet.py +++ b/Lib/test/test_smtpnet.py @@ -2,6 +2,7 @@ from test import support from test.support import import_helper from test.support import socket_helper +import os import smtplib import socket @@ -9,6 +10,8 @@ support.requires("network") +SMTP_TEST_SERVER = os.getenv('SMTP_TEST_SERVER', 'smtp.gmail.com') + def check_ssl_verifiy(host, port): context = ssl.create_default_context() with socket.create_connection((host, port)) as sock: @@ -22,7 +25,7 @@ def check_ssl_verifiy(host, port): class SmtpTest(unittest.TestCase): - testServer = 'smtp.gmail.com' + testServer = SMTP_TEST_SERVER remotePort = 587 def test_connect_starttls(self): @@ -44,7 +47,7 @@ def test_connect_starttls(self): class SmtpSSLTest(unittest.TestCase): - testServer = 'smtp.gmail.com' + testServer = SMTP_TEST_SERVER remotePort = 465 def test_connect(self): From 259012445c0f6cf2add30be4d22ac65902cb44d1 Mon Sep 17 00:00:00 2001 From: Diego Russo Date: Wed, 17 Apr 2024 13:43:58 +0100 Subject: [PATCH 2/2] Update Lib/test/test_smtpnet.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ɓukasz Langa --- Lib/test/test_smtpnet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_smtpnet.py b/Lib/test/test_smtpnet.py index fd98daaafb0667..d765746987bc4b 100644 --- a/Lib/test/test_smtpnet.py +++ b/Lib/test/test_smtpnet.py @@ -10,7 +10,7 @@ support.requires("network") -SMTP_TEST_SERVER = os.getenv('SMTP_TEST_SERVER', 'smtp.gmail.com') +SMTP_TEST_SERVER = os.getenv('CPYTHON_TEST_SMTP_SERVER', 'smtp.gmail.com') def check_ssl_verifiy(host, port): context = ssl.create_default_context()