From cd09d7e55d160edc454763d3fb6a48180988741a Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Thu, 16 Apr 2020 11:08:59 -0700 Subject: [PATCH] bpo-39793: use the same domain on make_msgid tests (GH-18698) (GH-19555) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit (cherry picked from commit 5565c30f0b25996a0e73477fc0e1e1aced52b926) Co-authored-by: Batuhan Taşkaya --- Lib/test/test_email/test_email.py | 10 ++++++---- .../Tests/2020-02-29-12-58-17.bpo-39793.Og2SUN.rst | 1 + 2 files changed, 7 insertions(+), 4 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 5414cf070cc1..9e5c6adca835 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -11,8 +11,8 @@ import textwrap 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,9 +3342,11 @@ multipart/report '.test-idstring@testdomain-string>') def test_make_msgid_default_domain(self): - self.assertTrue( - email.utils.make_msgid().endswith( - '@' + getfqdn() + '>')) + 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. 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 000000000000..6fa0d15ba2fd --- /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. -- 2.47.3