Skip to content

Commit ccf30e9

Browse files
bpo-39793: use the same domain on make_msgid tests (GH-18698) (GH-19554)
(cherry picked from commit 5565c30) Co-authored-by: Batuhan Taşkaya <[email protected]>
1 parent 3e72de9 commit ccf30e9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Lib/test/test_email/test_email.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from io import StringIO, BytesIO
1212
from itertools import chain
1313
from random import choice
14-
from socket import getfqdn
1514
from threading import Thread
15+
from unittest.mock import patch
1616

1717
import email
1818
import email.policy
@@ -3342,9 +3342,11 @@ def test_make_msgid_idstring(self):
33423342
'.test-idstring@testdomain-string>')
33433343

33443344
def test_make_msgid_default_domain(self):
3345-
self.assertTrue(
3346-
email.utils.make_msgid().endswith(
3347-
'@' + getfqdn() + '>'))
3345+
with patch('socket.getfqdn') as mock_getfqdn:
3346+
mock_getfqdn.return_value = domain = 'pythontest.example.com'
3347+
self.assertTrue(
3348+
email.utils.make_msgid().endswith(
3349+
'@' + domain + '>'))
33483350

33493351
def test_Generator_linend(self):
33503352
# Issue 14645.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use the same domain when testing ``make_msgid``. Patch by Batuhan Taskaya.

0 commit comments

Comments
 (0)