]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39793: use the same domain on make_msgid tests (GH-18698) (GH-19554)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 16 Apr 2020 18:07:52 +0000 (11:07 -0700)
committerGitHub <noreply@github.com>
Thu, 16 Apr 2020 18:07:52 +0000 (14:07 -0400)
(cherry picked from commit 5565c30f0b25996a0e73477fc0e1e1aced52b926)

Co-authored-by: Batuhan Taşkaya <batuhanosmantaskaya@gmail.com>
Lib/test/test_email/test_email.py
Misc/NEWS.d/next/Tests/2020-02-29-12-58-17.bpo-39793.Og2SUN.rst [new file with mode: 0644]

index 5414cf070cc12fc9cf736dc4918d0e72c2b00ac2..9e5c6adca835d947eb577b1c949a8c38da6e0e72 100644 (file)
@@ -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 (file)
index 0000000..6fa0d15
--- /dev/null
@@ -0,0 +1 @@
+Use the same domain when testing ``make_msgid``. Patch by Batuhan Taskaya.