From 4e01533046930d6fea34e851b22d21438cc6839f Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Sat, 29 Feb 2020 12:58:35 +0300 Subject: [PATCH 1/2] bpo-39793: use same domain on make_msgid tests --- Lib/test/test_email/test_email.py | 5 +++-- .../next/Tests/2020-02-29-12-58-17.bpo-39793.Og2SUN.rst | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Tests/2020-02-29-12-58-17.bpo-39793.Og2SUN.rst diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 8ec39190ea8da4..24a8236599d612 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -3342,9 +3342,10 @@ def test_make_msgid_idstring(self): '.test-idstring@testdomain-string>') def test_make_msgid_default_domain(self): + domain = getfqdn() # ensure the domain wont change (bpo-39793) self.assertTrue( - email.utils.make_msgid().endswith( - '@' + getfqdn() + '>')) + email.utils.make_msgid(domain=domain).endswith( + '@' + domain + '>')) def test_Generator_linend(self): # Issue 14645. diff --git a/Misc/NEWS.d/next/Tests/2020-02-29-12-58-17.bpo-39793.Og2SUN.rst b/Misc/NEWS.d/next/Tests/2020-02-29-12-58-17.bpo-39793.Og2SUN.rst new file mode 100644 index 00000000000000..6fa0d15ba2fdcb --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2020-02-29-12-58-17.bpo-39793.Og2SUN.rst @@ -0,0 +1 @@ +Use the same domain when testing ``make_msgid``. Patch by Batuhan Taskaya. From 50ddd37533ffdd83cb4c0123025b3d0616389988 Mon Sep 17 00:00:00 2001 From: Batuhan Taskaya Date: Thu, 5 Mar 2020 20:12:39 +0300 Subject: [PATCH 2/2] apply suggestions --- Lib/test/test_email/test_email.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index 24a8236599d612..59eabb00921942 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -11,8 +11,8 @@ from io import StringIO, BytesIO from itertools import chain from random import choice -from socket import getfqdn from threading import Thread +from unittest.mock import patch import email import email.policy @@ -3342,10 +3342,11 @@ def test_make_msgid_idstring(self): '.test-idstring@testdomain-string>') def test_make_msgid_default_domain(self): - domain = getfqdn() # ensure the domain wont change (bpo-39793) - self.assertTrue( - email.utils.make_msgid(domain=domain).endswith( - '@' + domain + '>')) + with patch('socket.getfqdn') as mock_getfqdn: + mock_getfqdn.return_value = domain = 'pythontest.example.com' + self.assertTrue( + email.utils.make_msgid().endswith( + '@' + domain + '>')) def test_Generator_linend(self): # Issue 14645. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy