Do not fail on DNSException when running test

Closes #12628
This commit is contained in:
Cédric Krier
2023-10-21 16:22:50 +02:00
parent d10a47f7d1
commit b43f3165fb
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ setup(name=name,
'barcode': ['python-barcode[images]'],
'qrcode': ['qrcode[pil]', 'webcolors'],
'completion': ['argcomplete'],
'email-validation': ['email-validator >= 2'],
'email-validation': ['email-validator >= 2', 'dnspython'],
},
zip_safe=False,
cmdclass={
+8 -1
View File
@@ -30,10 +30,17 @@ def set_from_header(message, sender, from_):
try:
from dns.exception import DNSException
from email_validator import EmailNotValidError, caching_resolver
from email_validator import validate_email as _validate_email
resolver = caching_resolver()
try:
resolver = caching_resolver()
except DNSException:
if Pool.test:
resolver = None
else:
raise
def validate_email(email):
emailinfo = _validate_email(