]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Test: Get the smtp test server using os.getenv() (#117979)
authorDiego Russo <diego.russo@arm.com>
Wed, 17 Apr 2024 13:31:48 +0000 (14:31 +0100)
committerGitHub <noreply@github.com>
Wed, 17 Apr 2024 13:31:48 +0000 (15:31 +0200)
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 <lukasz@langa.pl>
Lib/test/test_smtpnet.py

index 2e0dc1aa276f35828a148dfc614ab40b1f1eaf14..d765746987bc4b039066fd0e1828e1a231756232 100644 (file)
@@ -2,6 +2,7 @@ import unittest
 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 @@ ssl = import_helper.import_module("ssl")
 
 support.requires("network")
 
+SMTP_TEST_SERVER = os.getenv('CPYTHON_TEST_SMTP_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 @@ class SmtpTest(unittest.TestCase):
 
 
 class SmtpSSLTest(unittest.TestCase):
-    testServer = 'smtp.gmail.com'
+    testServer = SMTP_TEST_SERVER
     remotePort = 465
 
     def test_connect(self):