From 39b831d5b837bc33f88f9436aab1a39a1cf8cb2dde8b455be7dfb79c38f710f1 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Thu, 26 Nov 2020 09:03:43 +0000 Subject: [PATCH 1/6] - update to 1.26.2: * Fixed an issue where ``wrap_socket`` and ``CERT_REQUIRED`` wouldn't be imported properly on Python 2.7.8 and earlier (Pull #2052) * Fixed an issue where two ``User-Agent`` headers would be sent if a ``User-Agent`` header key is passed as ``bytes`` (Pull #2047) * Added support for HTTPS proxies contacting HTTPS servers (Pull #1923, Pull #1806) * Deprecated negotiating TLSv1 and TLSv1.1 by default. Users that still wish to use TLS earlier than 1.2 without a deprecation warning should opt-in explicitly by setting ``ssl_version=ssl.PROTOCOL_TLSv1_1`` (Pull #2002) **Starting in urllib3 v2.0: Connections that receive a ``DeprecationWarning`` will fail** * Deprecated ``Retry`` options ``Retry.DEFAULT_METHOD_WHITELIST``, ``Retry.DEFAULT_REDIRECT_HEADERS_BLACKLIST`` and ``Retry(method_whitelist=...)`` in favor of ``Retry.DEFAULT_ALLOWED_METHODS``, ``Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT``, and ``Retry(allowed_methods=...)`` (Pull #2000) **Starting in urllib3 v2.0: Deprecated options will be removed** * Added default ``User-Agent`` header to every request (Pull #1750) * Added ``urllib3.util.SKIP_HEADER`` for skipping ``User-Agent``, ``Accept-Encoding``, and ``Host`` headers from being automatically emitted with requests (Pull #2018) * Collapse ``transfer-encoding: chunked`` request data and framing into the same ``socket.send()`` call (Pull #1906) * Send ``http/1.1`` ALPN identifier with every TLS handshake by default (Pull #1894) * Properly terminate SecureTransport connections when CA verification fails (Pull #1977) * Don't emit an ``SNIMissingWarning`` when passing ``server_hostname=None`` to SecureTransport (Pull #1903) * Disabled requesting TLSv1.2 session tickets as they weren't being used by urllib3 (Pull #1970) * Suppress ``BrokenPipeError`` when writing request body after the server has closed the socket (Pull #1524) * Wrap ``ssl.SSLError`` that can be raised from reading a socket (e.g. "bad MAC") into an ``urllib3.exceptions.SSLError`` (Pull #1939) * Fix retry backoff time parsed from ``Retry-After`` header when given in the HTTP date format. The HTTP date was parsed as the local timezone OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=105 --- python-urllib3.changes | 36 ++++++++++++++++++++++++++++++++++++ python-urllib3.spec | 2 +- urllib3-1.25.10.tar.gz | 3 --- urllib3-1.26.2.tar.gz | 3 +++ 4 files changed, 40 insertions(+), 4 deletions(-) delete mode 100644 urllib3-1.25.10.tar.gz create mode 100644 urllib3-1.26.2.tar.gz diff --git a/python-urllib3.changes b/python-urllib3.changes index b1f096a..59c13a7 100644 --- a/python-urllib3.changes +++ b/python-urllib3.changes @@ -1,3 +1,39 @@ +------------------------------------------------------------------- +Thu Nov 26 09:02:30 UTC 2020 - Dirk Mueller + +- update to 1.26.2: + * Fixed an issue where ``wrap_socket`` and ``CERT_REQUIRED`` wouldn't + be imported properly on Python 2.7.8 and earlier (Pull #2052) + * Fixed an issue where two ``User-Agent`` headers would be sent if a + ``User-Agent`` header key is passed as ``bytes`` (Pull #2047) + * Added support for HTTPS proxies contacting HTTPS servers (Pull #1923, Pull #1806) + * Deprecated negotiating TLSv1 and TLSv1.1 by default. Users that + still wish to use TLS earlier than 1.2 without a deprecation warning + should opt-in explicitly by setting ``ssl_version=ssl.PROTOCOL_TLSv1_1`` (Pull #2002) + **Starting in urllib3 v2.0: Connections that receive a ``DeprecationWarning`` will fail** + * Deprecated ``Retry`` options ``Retry.DEFAULT_METHOD_WHITELIST``, ``Retry.DEFAULT_REDIRECT_HEADERS_BLACKLIST`` + and ``Retry(method_whitelist=...)`` in favor of ``Retry.DEFAULT_ALLOWED_METHODS``, + ``Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT``, and ``Retry(allowed_methods=...)`` + (Pull #2000) **Starting in urllib3 v2.0: Deprecated options will be removed** + * Added default ``User-Agent`` header to every request (Pull #1750) + * Added ``urllib3.util.SKIP_HEADER`` for skipping ``User-Agent``, ``Accept-Encoding``, + and ``Host`` headers from being automatically emitted with requests (Pull #2018) + * Collapse ``transfer-encoding: chunked`` request data and framing into + the same ``socket.send()`` call (Pull #1906) + * Send ``http/1.1`` ALPN identifier with every TLS handshake by default (Pull #1894) + * Properly terminate SecureTransport connections when CA verification fails (Pull #1977) + * Don't emit an ``SNIMissingWarning`` when passing ``server_hostname=None`` + to SecureTransport (Pull #1903) + * Disabled requesting TLSv1.2 session tickets as they weren't being used by urllib3 (Pull #1970) + * Suppress ``BrokenPipeError`` when writing request body after the server + has closed the socket (Pull #1524) + * Wrap ``ssl.SSLError`` that can be raised from reading a socket (e.g. "bad MAC") + into an ``urllib3.exceptions.SSLError`` (Pull #1939) + * Fix retry backoff time parsed from ``Retry-After`` header when given + in the HTTP date format. The HTTP date was parsed as the local timezone + rather than accounting for the timezone in the HTTP date (typically + UTC) (Pull #1932, Pull #1935, Pull #1938, Pull #1949) + ------------------------------------------------------------------- Wed Sep 9 16:49:22 UTC 2020 - Alberto Planas Dominguez diff --git a/python-urllib3.spec b/python-urllib3.spec index 16561df..4b0c096 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -28,7 +28,7 @@ %bcond_with test %endif Name: python-urllib3%{psuffix} -Version: 1.25.10 +Version: 1.26.2 Release: 0 Summary: HTTP library with thread-safe connection pooling, file post, and more License: MIT diff --git a/urllib3-1.25.10.tar.gz b/urllib3-1.25.10.tar.gz deleted file mode 100644 index af994de..0000000 --- a/urllib3-1.25.10.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:91056c15fa70756691db97756772bb1eb9678fa585d9184f24534b100dc60f4a -size 256875 diff --git a/urllib3-1.26.2.tar.gz b/urllib3-1.26.2.tar.gz new file mode 100644 index 0000000..f5f662e --- /dev/null +++ b/urllib3-1.26.2.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08 +size 286877 From 36a5e3eac935468269b679468ac86277f85a01cbfcc187fa755a1fe805400943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=C3=A9ta=20Machov=C3=A1?= Date: Fri, 11 Dec 2020 15:05:01 +0000 Subject: [PATCH 2/6] Accepting request 854910 from home:mcalabkova:branches:devel:languages:python - Fixed the testsuite and updated dependencies OBS-URL: https://build.opensuse.org/request/show/854910 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=106 --- python-urllib3.changes | 5 +++++ python-urllib3.spec | 34 ++++++++++++++-------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/python-urllib3.changes b/python-urllib3.changes index 59c13a7..4728096 100644 --- a/python-urllib3.changes +++ b/python-urllib3.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Dec 11 14:18:57 UTC 2020 - Markéta Machová + +- Fixed the testsuite and updated dependencies + ------------------------------------------------------------------- Thu Nov 26 09:02:30 UTC 2020 - Dirk Mueller diff --git a/python-urllib3.spec b/python-urllib3.spec index 4b0c096..d57cf43 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -46,29 +46,28 @@ Requires: ca-certificates-mozilla Requires: python-certifi Requires: python-cryptography >= 1.3.4 Requires: python-idna >= 2.0.0 -Requires: python-pyOpenSSL +Requires: python-pyOpenSSL >= 0.14 Requires: python-six >= 1.12.0 +Recommends: python-PySocks >= 1.5.6 +Recommends: python-brotlipy >= 0.6.0 BuildArch: noarch # for SSL module on older distros %if 0%{?suse_version} < 1500 BuildRequires: %{oldpython} %endif %if %{with test} -BuildRequires: %{python_module PySocks} +BuildRequires: %{python_module PySocks >= 1.5.6} BuildRequires: %{python_module brotlipy >= 0.6.0} -BuildRequires: %{python_module certifi} -BuildRequires: %{python_module cryptography >= 1.3.4} -BuildRequires: %{python_module idna >= 2.0.0} -BuildRequires: %{python_module mock >= 1.3.0} +BuildRequires: %{python_module mock} BuildRequires: %{python_module psutil} +BuildRequires: %{python_module pytest-freezegun} +BuildRequires: %{python_module pytest-timeout} BuildRequires: %{python_module pytest} -BuildRequires: %{python_module six >= 1.12.0} -BuildRequires: %{python_module tornado < 6} +BuildRequires: %{python_module python-dateutil} +BuildRequires: %{python_module tornado >= 6} BuildRequires: %{python_module trustme >= 0.5.3} BuildRequires: %{python_module urllib3 >= %{version}} %endif -Recommends: python-PySocks >= 1.5.6 -Recommends: python-brotlipy >= 0.6.0 %python_subpackages %description @@ -128,18 +127,13 @@ ln -sf %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.pyc %if %{with test} %check -skiplist='not test_select_interrupt_exception and not test_selector_error and not timeout and not test_request_host_header_ignores_fqdn_dot and not test_dotted_fqdn and not TestImportWithoutSSL and not test_ssl_failed_fingerprint_verification' -case $(uname -m) in -ppc*) -skiplist="$skiplist and not test_select_timing and not test_select_multiple_interrupts_with_event and not test_interrupt_wait_for_read_with_event and not test_select_interrupt_with_event";; -esac -# the certificate validation is much stricter in new openssl so skip -# tests which would not validate it -skiplist="$skiplist and not test_client_no_intermediate" - +# still broken with new ssl +skiplist='test_import_urllib3' +# skip some randomly failing tests (mostly on i586, but sometimes they fail on other architectures) +skiplist="$skiplist or test_ssl_read_timeout or test_ssl_failed_fingerprint_verification or test_ssl_custom_validation_failure_terminates" export PYTHONDONTWRITEBYTECODE=1 export LANG="en_US.UTF8" -%pytest -k "${skiplist}" +%pytest -k "not (${skiplist})" %endif %if ! %{with test} From 27a1b5088610dbdef2a3a43774e98246984022d51f2e277bf11459dd11b2927f Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Sat, 12 Dec 2020 11:58:21 +0000 Subject: [PATCH 3/6] Accepting request 855327 from home:mcepl:branches:devel:tools:scm - Add remove_mock.patch to remove dependency on the external mock package (gh#urllib3/urllib3#2108). OBS-URL: https://build.opensuse.org/request/show/855327 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=107 --- python-urllib3.changes | 6 ++ python-urllib3.spec | 11 ++- remove_mock.patch | 180 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 remove_mock.patch diff --git a/python-urllib3.changes b/python-urllib3.changes index 4728096..128eebf 100644 --- a/python-urllib3.changes +++ b/python-urllib3.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Fri Dec 11 22:52:59 UTC 2020 - Matej Cepl + +- Add remove_mock.patch to remove dependency on the external mock + package (gh#urllib3/urllib3#2108). + ------------------------------------------------------------------- Fri Dec 11 14:18:57 UTC 2020 - Markéta Machová diff --git a/python-urllib3.spec b/python-urllib3.spec index d57cf43..1eabaec 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -37,6 +37,9 @@ URL: https://urllib3.readthedocs.org/ Source: https://files.pythonhosted.org/packages/source/u/urllib3/urllib3-%{version}.tar.gz # Wrapper for ssl to unbundle ssl_match_hostname Source1: ssl_match_hostname_py3.py +# PATCH-FIX-UPSTREAM remove_mock.patch gh#urllib3/urllib3#2108 mcepl@suse.com +# remove dependency on the external module mock +Patch0: remove_mock.patch BuildRequires: %{python_module setuptools} BuildRequires: %{python_module six} BuildRequires: fdupes @@ -58,7 +61,6 @@ BuildRequires: %{oldpython} %if %{with test} BuildRequires: %{python_module PySocks >= 1.5.6} BuildRequires: %{python_module brotlipy >= 0.6.0} -BuildRequires: %{python_module mock} BuildRequires: %{python_module psutil} BuildRequires: %{python_module pytest-freezegun} BuildRequires: %{python_module pytest-timeout} @@ -87,7 +89,8 @@ Highlights Requests which is also powered by urllib3. %prep -%setup -q -n urllib3-%{version} +%autosetup -p1 -n urllib3-%{version} + find . -type f -exec chmod a-x '{}' \; find . -name __pycache__ -type d -exec rm -fr {} + @@ -131,8 +134,8 @@ ln -sf %{python3_sitelib}/__pycache__/six.cpython-%{python3_version_nodots}.pyc skiplist='test_import_urllib3' # skip some randomly failing tests (mostly on i586, but sometimes they fail on other architectures) skiplist="$skiplist or test_ssl_read_timeout or test_ssl_failed_fingerprint_verification or test_ssl_custom_validation_failure_terminates" -export PYTHONDONTWRITEBYTECODE=1 -export LANG="en_US.UTF8" +# gh#urllib3/urllib3#2109 +skiplist="$skiplist or test_timeout_errors_cause_retries" %pytest -k "not (${skiplist})" %endif diff --git a/remove_mock.patch b/remove_mock.patch new file mode 100644 index 0000000..822e7f4 --- /dev/null +++ b/remove_mock.patch @@ -0,0 +1,180 @@ +--- a/docs/conf.py ++++ b/docs/conf.py +@@ -14,7 +14,7 @@ sys.path.insert(0, root_path) + # Mock some expensive/platform-specific modules so build will work. + # (https://read-the-docs.readthedocs.io/en/latest/faq.html#\ + # i-get-import-errors-on-libraries-that-depend-on-c-modules) +-import mock ++import unittest.mock as mock + + + class MockModule(mock.Mock): +@@ -77,7 +77,7 @@ html_logo = "images/banner.svg" + + html_theme_options = { + "announcement": """ +- + Sponsor urllib3 v2.0 on Open Collective + +--- a/test/appengine/test_urlfetch.py ++++ b/test/appengine/test_urlfetch.py +@@ -5,7 +5,7 @@ Engine-patched version of httplib to mak + import httplib + import pytest + import StringIO +-from mock import patch ++from unittest.mock import patch + + from ..test_no_ssl import TestWithoutSSL + +--- a/test/contrib/test_pyopenssl.py ++++ b/test/contrib/test_pyopenssl.py +@@ -1,7 +1,7 @@ + # -*- coding: utf-8 -*- + import os + +-import mock ++import unittest.mock as mock + import pytest + + try: +--- a/test/contrib/test_pyopenssl_dependencies.py ++++ b/test/contrib/test_pyopenssl_dependencies.py +@@ -1,6 +1,6 @@ + # -*- coding: utf-8 -*- + import pytest +-from mock import Mock, patch ++from unittest.mock import Mock, patch + + try: + from urllib3.contrib.pyopenssl import extract_from_urllib3, inject_into_urllib3 +--- a/test/test_connection.py ++++ b/test/test_connection.py +@@ -1,6 +1,6 @@ + import datetime + +-import mock ++import unittest.mock as mock + import pytest + + from urllib3.connection import RECENT_DATE, CertificateError, _match_hostname +--- a/test/test_connectionpool.py ++++ b/test/test_connectionpool.py +@@ -6,7 +6,7 @@ from ssl import SSLError as BaseSSLError + from test import SHORT_TIMEOUT + + import pytest +-from mock import Mock ++from unittest.mock import Mock + + from dummyserver.server import DEFAULT_CA + from urllib3._collections import HTTPHeaderDict +--- a/test/test_queue_monkeypatch.py ++++ b/test/test_queue_monkeypatch.py +@@ -1,6 +1,6 @@ + from __future__ import absolute_import + +-import mock ++import unittest.mock as mock + import pytest + + from urllib3 import HTTPConnectionPool +--- a/test/test_response.py ++++ b/test/test_response.py +@@ -9,7 +9,7 @@ from base64 import b64decode + from io import BufferedReader, BytesIO, TextIOWrapper + from test import onlyBrotlipy + +-import mock ++import unittest.mock as mock + import pytest + import six + +--- a/test/test_retry.py ++++ b/test/test_retry.py +@@ -1,6 +1,6 @@ + import warnings + +-import mock ++import unittest.mock as mock + import pytest + + from urllib3.exceptions import ( +--- a/test/test_retry_deprecated.py ++++ b/test/test_retry_deprecated.py +@@ -1,7 +1,7 @@ + # This is a copy-paste of test_retry.py with extra asserts about deprecated options. It will be removed for v2. + import warnings + +-import mock ++import unittest.mock as mock + import pytest + + from urllib3.exceptions import ( +--- a/test/test_ssl.py ++++ b/test/test_ssl.py +@@ -1,6 +1,6 @@ + from test import notPyPy2 + +-import mock ++import unittest.mock as mock + import pytest + + from urllib3.exceptions import SNIMissingWarning +--- a/test/test_ssltransport.py ++++ b/test/test_ssltransport.py +@@ -4,7 +4,7 @@ import socket + import ssl + import sys + +-import mock ++import unittest.mock as mock + import pytest + + from dummyserver.server import DEFAULT_CA, DEFAULT_CERTS +--- a/test/test_util.py ++++ b/test/test_util.py +@@ -9,7 +9,7 @@ from itertools import chain + from test import notBrotlipy, onlyBrotlipy, onlyPy2, onlyPy3 + + import pytest +-from mock import Mock, patch ++from unittest.mock import Mock, patch + + from urllib3 import add_stderr_logger, disable_warnings, util + from urllib3.exceptions import ( +--- a/test/with_dummyserver/test_connectionpool.py ++++ b/test/with_dummyserver/test_connectionpool.py +@@ -10,7 +10,7 @@ import warnings + from test import LONG_TIMEOUT, SHORT_TIMEOUT, onlyPy2 + from threading import Event + +-import mock ++import unittest.mock as mock + import pytest + import six + +--- a/test/with_dummyserver/test_https.py ++++ b/test/with_dummyserver/test_https.py +@@ -19,7 +19,7 @@ from test import ( + resolvesLocalhostFQDN, + ) + +-import mock ++import unittest.mock as mock + import pytest + import trustme + +--- a/test/with_dummyserver/test_socketlevel.py ++++ b/test/with_dummyserver/test_socketlevel.py +@@ -52,7 +52,7 @@ from test import ( + ) + from threading import Event + +-import mock ++import unittest.mock as mock + import pytest + import trustme + From ba460dce102ea7a8e76dcc83367647aa5e4d58190110fd04802f0315dc7cf45e Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Sat, 12 Dec 2020 19:04:14 +0000 Subject: [PATCH 4/6] Resolve conflict OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=108 --- python-urllib3.spec | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python-urllib3.spec b/python-urllib3.spec index 1eabaec..63c98f4 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -61,6 +61,12 @@ BuildRequires: %{oldpython} %if %{with test} BuildRequires: %{python_module PySocks >= 1.5.6} BuildRequires: %{python_module brotlipy >= 0.6.0} +BuildRequires: %{python_module certifi} +BuildRequires: %{python_module cryptography >= 1.3.4} +BuildRequires: %{python_module dateutil} +BuildRequires: %{python_module flaky} +BuildRequires: %{python_module idna >= 2.0.0} +BuildRequires: %{python_module mock >= 1.3.0} BuildRequires: %{python_module psutil} BuildRequires: %{python_module pytest-freezegun} BuildRequires: %{python_module pytest-timeout} From 6c92a26185f77b94c871d7a8a046463d543bbdc2356b3d115da619683589e126 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 14 Dec 2020 07:29:10 +0000 Subject: [PATCH 5/6] Accepting request 855675 from home:mcepl:branches:devel:tools:scm - We don't need to break Python 2.7 OBS-URL: https://build.opensuse.org/request/show/855675 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=109 --- python-urllib3.changes | 5 ++ python-urllib3.spec | 3 ++ remove_mock.patch | 114 +++++++++++++++++++++++++++++------------ 3 files changed, 89 insertions(+), 33 deletions(-) diff --git a/python-urllib3.changes b/python-urllib3.changes index 128eebf..ccbb66f 100644 --- a/python-urllib3.changes +++ b/python-urllib3.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sun Dec 13 21:46:22 UTC 2020 - Matej Cepl + +- We don't need to break Python 2.7 + ------------------------------------------------------------------- Fri Dec 11 22:52:59 UTC 2020 - Matej Cepl diff --git a/python-urllib3.spec b/python-urllib3.spec index 63c98f4..2b41477 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -75,6 +75,9 @@ BuildRequires: %{python_module python-dateutil} BuildRequires: %{python_module tornado >= 6} BuildRequires: %{python_module trustme >= 0.5.3} BuildRequires: %{python_module urllib3 >= %{version}} +%if "%{python_flavor}" == "python2" +BuildRequires: %{python_module mock} +%endif %endif %python_subpackages diff --git a/remove_mock.patch b/remove_mock.patch index 822e7f4..d728f6d 100644 --- a/remove_mock.patch +++ b/remove_mock.patch @@ -1,15 +1,18 @@ --- a/docs/conf.py +++ b/docs/conf.py -@@ -14,7 +14,7 @@ sys.path.insert(0, root_path) +@@ -14,7 +14,10 @@ sys.path.insert(0, root_path) # Mock some expensive/platform-specific modules so build will work. # (https://read-the-docs.readthedocs.io/en/latest/faq.html#\ # i-get-import-errors-on-libraries-that-depend-on-c-modules) -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock class MockModule(mock.Mock): -@@ -77,7 +77,7 @@ html_logo = "images/banner.svg" +@@ -77,7 +80,7 @@ html_logo = "images/banner.svg" html_theme_options = { "announcement": """ @@ -20,161 +23,206 @@ --- a/test/appengine/test_urlfetch.py +++ b/test/appengine/test_urlfetch.py -@@ -5,7 +5,7 @@ Engine-patched version of httplib to mak +@@ -5,7 +5,10 @@ Engine-patched version of httplib to mak import httplib import pytest import StringIO -from mock import patch -+from unittest.mock import patch ++try: ++ from unittest.mock import patch ++except ImportError: ++ from mock import patch from ..test_no_ssl import TestWithoutSSL --- a/test/contrib/test_pyopenssl.py +++ b/test/contrib/test_pyopenssl.py -@@ -1,7 +1,7 @@ +@@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- import os -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest try: --- a/test/contrib/test_pyopenssl_dependencies.py +++ b/test/contrib/test_pyopenssl_dependencies.py -@@ -1,6 +1,6 @@ +@@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- import pytest -from mock import Mock, patch -+from unittest.mock import Mock, patch ++try: ++ from unittest.mock import Mock, patch ++except ImportError: ++ from mock import Mock, patch try: from urllib3.contrib.pyopenssl import extract_from_urllib3, inject_into_urllib3 --- a/test/test_connection.py +++ b/test/test_connection.py -@@ -1,6 +1,6 @@ +@@ -1,6 +1,9 @@ import datetime -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from urllib3.connection import RECENT_DATE, CertificateError, _match_hostname --- a/test/test_connectionpool.py +++ b/test/test_connectionpool.py -@@ -6,7 +6,7 @@ from ssl import SSLError as BaseSSLError +@@ -6,7 +6,10 @@ from ssl import SSLError as BaseSSLError from test import SHORT_TIMEOUT import pytest -from mock import Mock -+from unittest.mock import Mock ++try: ++ from unittest.mock import Mock ++except ImportError: ++ from mock import Mock from dummyserver.server import DEFAULT_CA from urllib3._collections import HTTPHeaderDict --- a/test/test_queue_monkeypatch.py +++ b/test/test_queue_monkeypatch.py -@@ -1,6 +1,6 @@ +@@ -1,6 +1,9 @@ from __future__ import absolute_import -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from urllib3 import HTTPConnectionPool --- a/test/test_response.py +++ b/test/test_response.py -@@ -9,7 +9,7 @@ from base64 import b64decode +@@ -9,7 +9,10 @@ from base64 import b64decode from io import BufferedReader, BytesIO, TextIOWrapper from test import onlyBrotlipy -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest import six --- a/test/test_retry.py +++ b/test/test_retry.py -@@ -1,6 +1,6 @@ +@@ -1,6 +1,9 @@ import warnings -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from urllib3.exceptions import ( --- a/test/test_retry_deprecated.py +++ b/test/test_retry_deprecated.py -@@ -1,7 +1,7 @@ +@@ -1,7 +1,10 @@ # This is a copy-paste of test_retry.py with extra asserts about deprecated options. It will be removed for v2. import warnings -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from urllib3.exceptions import ( --- a/test/test_ssl.py +++ b/test/test_ssl.py -@@ -1,6 +1,6 @@ +@@ -1,6 +1,9 @@ from test import notPyPy2 -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from urllib3.exceptions import SNIMissingWarning --- a/test/test_ssltransport.py +++ b/test/test_ssltransport.py -@@ -4,7 +4,7 @@ import socket +@@ -4,7 +4,10 @@ import socket import ssl import sys -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from dummyserver.server import DEFAULT_CA, DEFAULT_CERTS --- a/test/test_util.py +++ b/test/test_util.py -@@ -9,7 +9,7 @@ from itertools import chain +@@ -9,7 +9,10 @@ from itertools import chain from test import notBrotlipy, onlyBrotlipy, onlyPy2, onlyPy3 import pytest -from mock import Mock, patch -+from unittest.mock import Mock, patch ++try: ++ from unittest.mock import Mock, patch ++except ImportError: ++ from mock import Mock, patch from urllib3 import add_stderr_logger, disable_warnings, util from urllib3.exceptions import ( --- a/test/with_dummyserver/test_connectionpool.py +++ b/test/with_dummyserver/test_connectionpool.py -@@ -10,7 +10,7 @@ import warnings +@@ -10,7 +10,10 @@ import warnings from test import LONG_TIMEOUT, SHORT_TIMEOUT, onlyPy2 from threading import Event -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest import six --- a/test/with_dummyserver/test_https.py +++ b/test/with_dummyserver/test_https.py -@@ -19,7 +19,7 @@ from test import ( +@@ -19,7 +19,10 @@ from test import ( resolvesLocalhostFQDN, ) -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest import trustme --- a/test/with_dummyserver/test_socketlevel.py +++ b/test/with_dummyserver/test_socketlevel.py -@@ -52,7 +52,7 @@ from test import ( +@@ -52,7 +52,10 @@ from test import ( ) from threading import Event -import mock -+import unittest.mock as mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest import trustme From 0d81b01f4f88985eade02aaf7bd3a63325531101c516b90309e9b20527aadb87 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 14 Dec 2020 17:20:19 +0000 Subject: [PATCH 6/6] Accepting request 855783 from home:bnavigator:branches:devel:languages:python - If you skip_python2 you don't need mock. mcepl: This still has the wrong condition, we talked about yesterday. OBS-URL: https://build.opensuse.org/request/show/855783 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-urllib3?expand=0&rev=110 --- python-urllib3.changes | 5 +++++ python-urllib3.spec | 8 -------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/python-urllib3.changes b/python-urllib3.changes index ccbb66f..158a52b 100644 --- a/python-urllib3.changes +++ b/python-urllib3.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Dec 14 15:21:26 UTC 2020 - Benjamin Greiner + +- If you skip_python2 you don't need mock. + ------------------------------------------------------------------- Sun Dec 13 21:46:22 UTC 2020 - Matej Cepl diff --git a/python-urllib3.spec b/python-urllib3.spec index 2b41477..300c1d4 100644 --- a/python-urllib3.spec +++ b/python-urllib3.spec @@ -18,7 +18,6 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 -%define oldpython python %global flavor @BUILD_FLAVOR@%{nil} %if "%{flavor}" == "test" %define psuffix -test @@ -54,10 +53,6 @@ Requires: python-six >= 1.12.0 Recommends: python-PySocks >= 1.5.6 Recommends: python-brotlipy >= 0.6.0 BuildArch: noarch -# for SSL module on older distros -%if 0%{?suse_version} < 1500 -BuildRequires: %{oldpython} -%endif %if %{with test} BuildRequires: %{python_module PySocks >= 1.5.6} BuildRequires: %{python_module brotlipy >= 0.6.0} @@ -75,9 +70,6 @@ BuildRequires: %{python_module python-dateutil} BuildRequires: %{python_module tornado >= 6} BuildRequires: %{python_module trustme >= 0.5.3} BuildRequires: %{python_module urllib3 >= %{version}} -%if "%{python_flavor}" == "python2" -BuildRequires: %{python_module mock} -%endif %endif %python_subpackages