Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Test: Get the smtp test server using os.getenv() #117979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Lib/test/test_smtpnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
from test import support
from test.support import import_helper
from test.support import socket_helper
import os
import smtplib
import socket

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:
Expand All @@ -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):
Expand All @@ -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):
Expand Down