diff --git a/dont-require-resolv-tests.patch b/dont-require-resolv-tests.patch new file mode 100644 index 0000000..45efa13 --- /dev/null +++ b/dont-require-resolv-tests.patch @@ -0,0 +1,59 @@ +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 + diff --git a/email_validator-1.3.1.tar.gz b/email_validator-1.3.1.tar.gz deleted file mode 100644 index 3cbe1d9..0000000 --- a/email_validator-1.3.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b7b154e0bce97b7e8063d04ea5bbc4c0b8a51ec55011278e47765578dce9e4b0 -size 28691 diff --git a/email_validator-2.0.0.tar.gz b/email_validator-2.0.0.tar.gz new file mode 100644 index 0000000..b166b8f --- /dev/null +++ b/email_validator-2.0.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0cd656b4c2cba10bcb518808f800bdde74af0c01a2522a9d475b3b1954d98f01 +size 39142 diff --git a/ignore-urllib3-pyopenssl-warning.patch b/ignore-urllib3-pyopenssl-warning.patch index c878d1f..52d49b0 100644 --- a/ignore-urllib3-pyopenssl-warning.patch +++ b/ignore-urllib3-pyopenssl-warning.patch @@ -1,9 +1,11 @@ -Index: python-email-validator-1.2.1/setup.cfg +Index: python-email-validator-2.0.0/setup.cfg =================================================================== ---- python-email-validator-1.2.1.orig/setup.cfg -+++ python-email-validator-1.2.1/setup.cfg -@@ -43,3 +43,4 @@ max-line-length = 120 +--- python-email-validator-2.0.0.orig/setup.cfg ++++ python-email-validator-2.0.0/setup.cfg +@@ -43,5 +43,6 @@ max-line-length = 120 testpaths = tests filterwarnings = error + ignore:.*urllib3.contrib.pyopenssl.*:DeprecationWarning + markers = + network: mark a test as requiring Internet access. diff --git a/python-email-validator.changes b/python-email-validator.changes index 9db07ca..90afade 100644 --- a/python-email-validator.changes +++ b/python-email-validator.changes @@ -1,3 +1,57 @@ +------------------------------------------------------------------- +Thu May 25 08:23:47 UTC 2023 - Daniel Garcia + +- 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 + address in the error message. + * The email field on the returned ValidatedEmail object has been + renamed to normalized to be clearer about its importance, but + access via .email is also still supported. + * Some mailbox names like postmaster are now normalized to lowercase + per RFC 2142. + * The library has been reorganized internally into smaller modules. + * The tests have been reorganized and expanded. Deliverability tests + now mostly use captured DNS responses so they can be run off-line. + * The main tool now reads options to validate_email from environment + variables. + * Type annotations have been added to the exported methods and the + ValidatedEmail class and some internal methods. + * The old dict-like pattern for the return value of validate_email + is deprecated. + + Versions 2.0.0.post1 and 2.0.0.post2 corrected some packaging + issues. 2.0.0.post2 also added a check for an invalid combination of + arguments. + ------------------------------------------------------------------- Thu May 25 07:18:27 UTC 2023 - Daniel Garcia diff --git a/python-email-validator.spec b/python-email-validator.spec index fd24742..2f79fcf 100644 --- a/python-email-validator.spec +++ b/python-email-validator.spec @@ -19,7 +19,7 @@ %{?sle15_python_module_pythons} %define skip_python2 1 Name: python-email-validator -Version: 1.3.1 +Version: 2.0.0 Release: 0 Summary: A robust email syntax and deliverability validation library for Python License: CC0-1.0 @@ -28,6 +28,8 @@ Source: https://github.com/JoshData/python-email-validator/archive/refs/ # PATCH-FIX-OPENSUSE Ignore DeprecationWarning until requests-toolbelt is fixed # (Pulled in by dnspython) Patch0: ignore-urllib3-pyopenssl-warning.patch +# PATCH-FIX-OPENSUSE do not require /etc/resolv.conf for testing +Patch1: dont-require-resolv-tests.patch BuildRequires: %{python_module dnspython >= 1.15.0} BuildRequires: %{python_module idna >= 2.0.0} BuildRequires: %{python_module pytest >= 5.0} @@ -71,7 +73,9 @@ Key features: %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%pytest tests -k 'not (test_deliverability_no_records or test_deliverability_found or test_deliverability_fails or test_deliverability_dns_timeout or test_main_single_good_input or test_main_multi_input or test_main_input_shim or test_validate_email__with_caching_resolver or test_validate_email__with_configured_resolver or test_email_example_reserved_domain)' +echo "nameserver 1.1.1.1" > resolv.conf +export RESOLV_FILE=$PWD/resolv.conf +%pytest tests %post %python_install_alternative email_validator