python-email-validator/dont-require-resolv-tests.patch
Daniel Garcia bcb82af895 - Add dont-require-resolv-tests.patch to make tests run without an
existing /etc/resolv.conf file
- Update to 2.0.0:
  This is a major update to the library, but since email address specs
  haven't changed there should be no significant changes to which
  email addresses are considered valid or invalid with default
  options. There are new options for accepting unusual email addresses
  that were previously always rejected, some changes to how DNS errors
  are handled, many changes in error message text, and major internal
  improvements including the addition of type annotations. Python 3.7+
  is now required. Details follow:
  * Python 2.x and 3.x versions through 3.6, and dnspython 1.x, are no
    longer supported. Python 3.7+ with dnspython 2.x are now required.
  * The dnspython package is no longer required if DNS checks are not
    used, although it will install automatically.
  * NoNameservers and NXDOMAIN DNS errors are now handled differently:
    NoNameservers no longer fails validation, and NXDOMAIN now skips
    checking for an A/AAAA fallback and goes straight to failing
    validation.
  * Some syntax error messages have changed because they are now
    checked explicitly rather than as a part of other checks.
  * The quoted-string local part syntax (e.g. multiple @-signs,
    spaces, etc. if surrounded by quotes) and domain-literal addresses
    (e.g. @[192.XXX...] or @[IPv6:...]) are now parsed but not
    considered valid by default. Better error messages are now given
    for these addresses since it can be confusing for a technically
    valid address to be rejected, and new allow_quoted_local and
    allow_domain_literal options are added to allow these addresses if
    you really need them.
  * Some other error messages have changed to not repeat the email

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-email-validator?expand=0&rev=11
2023-05-25 08:33:48 +00:00

60 lines
2.4 KiB
Diff

Index: python-email-validator-2.0.0/email_validator/deliverability.py
===================================================================
--- python-email-validator-2.0.0.orig/email_validator/deliverability.py
+++ python-email-validator-2.0.0/email_validator/deliverability.py
@@ -6,11 +6,11 @@ import dns.resolver
import dns.exception
-def caching_resolver(*, timeout: Optional[int] = None, cache=None):
+def caching_resolver(*, timeout: Optional[int] = None, cache=None, resolv=None):
if timeout is None:
from . import DEFAULT_TIMEOUT
timeout = DEFAULT_TIMEOUT
- resolver = dns.resolver.Resolver()
+ resolver = dns.resolver.Resolver(filename=resolv or '/etc/resolv.conf')
resolver.cache = cache or dns.resolver.LRUCache() # type: ignore
resolver.lifetime = timeout # type: ignore # timeout, in seconds
return resolver
Index: python-email-validator-2.0.0/tests/mocked_dns_response.py
===================================================================
--- python-email-validator-2.0.0.orig/tests/mocked_dns_response.py
+++ python-email-validator-2.0.0/tests/mocked_dns_response.py
@@ -1,5 +1,6 @@
import dns.resolver
import json
+import os
import os.path
import pytest
@@ -32,7 +33,8 @@ class MockedDnsResponseData:
# Return a new dns.resolver.Resolver configured for caching
# using the singleton instance.
- return caching_resolver(cache=MockedDnsResponseData.INSTANCE)
+ return caching_resolver(cache=MockedDnsResponseData.INSTANCE,
+ resolv=os.environ.get('RESOLV_FILE'))
def __init__(self):
self.data = {}
Index: python-email-validator-2.0.0/tests/test_deliverability.py
===================================================================
--- python-email-validator-2.0.0.orig/tests/test_deliverability.py
+++ python-email-validator-2.0.0/tests/test_deliverability.py
@@ -1,5 +1,6 @@
import pytest
import re
+import os
from email_validator import EmailUndeliverableError, \
validate_email, caching_resolver
@@ -73,7 +74,7 @@ def test_caching_dns_resolver():
self.cache[key] = value
cache = TestCache()
- resolver = caching_resolver(timeout=1, cache=cache)
+ resolver = caching_resolver(timeout=1, cache=cache, resolv=os.environ.get('RESOLV_FILE'))
validate_email("test@gmail.com", dns_resolver=resolver)
assert len(cache.cache) == 1