From c8596ae951828a5293ee0c85506e2ebf4f62f5372595a0d08c34a3d2c16f898c Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Sat, 12 Dec 2020 12:13:15 +0000 Subject: [PATCH 1/3] Accepting request 855341 from home:mcepl:branches:devel:tools:scm - Add remove_mock.patch to remove dependency on the external mock OBS-URL: https://build.opensuse.org/request/show/855341 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-requests-toolbelt?expand=0&rev=16 --- python-requests-toolbelt.changes | 5 + python-requests-toolbelt.spec | 10 +- remove_mock.patch | 172 +++++++++++++++++++++++++++++++ 3 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 remove_mock.patch diff --git a/python-requests-toolbelt.changes b/python-requests-toolbelt.changes index c36ca95..7856328 100644 --- a/python-requests-toolbelt.changes +++ b/python-requests-toolbelt.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Dec 7 08:09:35 UTC 2020 - Matej Cepl + +- Add remove_mock.patch to remove dependency on the external mock + ------------------------------------------------------------------- Mon May 6 14:06:37 UTC 2019 - Tomáš Chvátal diff --git a/python-requests-toolbelt.spec b/python-requests-toolbelt.spec index 8dcc495..81f52e2 100644 --- a/python-requests-toolbelt.spec +++ b/python-requests-toolbelt.spec @@ -1,7 +1,7 @@ # # spec file for package python-requests-toolbelt # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -26,6 +26,9 @@ Group: Development/Languages/Python URL: https://github.com/requests/toolbelt Source: https://files.pythonhosted.org/packages/source/r/requests-toolbelt/requests-toolbelt-%{version}.tar.gz Patch0: fix-tests.patch +# PATCH-FIX-UPSTREAM remove_mock.patch bsc#[0-9]+ mcepl@suse.com +# remove dependency on the external mock package +Patch1: remove_mock.patch BuildRequires: %{python_module requests >= 2.12.2} BuildRequires: %{python_module setuptools} BuildRequires: fdupes @@ -34,7 +37,6 @@ Requires: python-requests >= 2.12.2 BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module betamax >= 0.5.0} -BuildRequires: %{python_module mock} BuildRequires: %{python_module pyOpenSSL} BuildRequires: %{python_module pytest} # /SECTION @@ -47,8 +49,8 @@ really belong in ``requests`` proper. The minimum tested requests version is some idiosyncracies prevent effective or sane testing on that version. %prep -%setup -q -n requests-toolbelt-%{version} -%patch0 -p1 +%autosetup -p1 -n requests-toolbelt-%{version} + rm -rf requests_toolbelt.egg-info # requires network access rm -v tests/test_multipart_encoder.py diff --git a/remove_mock.patch b/remove_mock.patch new file mode 100644 index 0000000..138c661 --- /dev/null +++ b/remove_mock.patch @@ -0,0 +1,172 @@ +--- + dev-requirements.txt | 1 - + tests/test_appengine_adapter.py | 2 +- + tests/test_auth.py | 2 +- + tests/test_downloadutils.py | 2 +- + tests/test_dump.py | 2 +- + tests/test_multipart_decoder.py | 2 +- + tests/test_proxy_digest_auth.py | 2 +- + tests/test_socket_options_adapter.py | 2 +- + tests/test_ssladapter.py | 2 +- + tests/threaded/test_api.py | 2 +- + tests/threaded/test_pool.py | 2 +- + tests/threaded/test_thread.py | 2 +- + tox.ini | 1 - + 13 files changed, 11 insertions(+), 13 deletions(-) + +--- a/tests/test_appengine_adapter.py ++++ b/tests/test_appengine_adapter.py +@@ -2,7 +2,7 @@ + """Tests for the AppEngineAdapter.""" + import sys + +-import mock ++from unittest import mock + import pytest + import requests + +--- a/tests/test_auth.py ++++ b/tests/test_auth.py +@@ -1,7 +1,7 @@ + # -*- coding: utf-8 -*- + import requests + import unittest +-import mock ++from unittest import mock + + from requests_toolbelt.auth.guess import GuessAuth, GuessProxyAuth + from . import get_betamax +--- a/tests/test_downloadutils.py ++++ b/tests/test_downloadutils.py +@@ -8,7 +8,7 @@ import tempfile + import requests + from requests_toolbelt.downloadutils import stream + from requests_toolbelt.downloadutils import tee +-import mock ++from unittest import mock + import pytest + + from . import get_betamax +--- a/tests/test_dump.py ++++ b/tests/test_dump.py +@@ -12,7 +12,7 @@ very complex and high-level. + from requests_toolbelt._compat import HTTPHeaderDict + from requests_toolbelt.utils import dump + +-import mock ++from unittest import mock + import pytest + import requests + +--- a/tests/test_multipart_decoder.py ++++ b/tests/test_multipart_decoder.py +@@ -2,7 +2,7 @@ + import io + import sys + import unittest +-import mock ++from unittest import mock + import pytest + import requests + from requests_toolbelt.multipart.decoder import BodyPart +--- a/tests/test_proxy_digest_auth.py ++++ b/tests/test_proxy_digest_auth.py +@@ -2,7 +2,7 @@ + """Test proxy digest authentication.""" + + import unittest +-import mock ++from unittest import mock + + import requests + from requests_toolbelt.auth import http_proxy_digest +--- a/tests/test_socket_options_adapter.py ++++ b/tests/test_socket_options_adapter.py +@@ -3,7 +3,7 @@ + import contextlib + import socket + +-import mock ++from unittest import mock + import requests + from requests_toolbelt._compat import poolmanager + +--- a/tests/test_ssladapter.py ++++ b/tests/test_ssladapter.py +@@ -1,5 +1,5 @@ + # -*- coding: utf-8 -*- +-import mock ++from unittest import mock + import pytest + import requests + import unittest +--- a/tests/threaded/test_api.py ++++ b/tests/threaded/test_api.py +@@ -1,6 +1,6 @@ + """Module containing tests for requests_toolbelt.threaded API.""" + +-import mock ++from unittest import mock + import pytest + + from requests_toolbelt._compat import queue +--- a/tests/threaded/test_pool.py ++++ b/tests/threaded/test_pool.py +@@ -5,7 +5,7 @@ except ImportError: + import Queue as queue + import unittest + +-import mock ++from unittest import mock + import pytest + + from requests_toolbelt.threaded import pool +--- a/tests/threaded/test_thread.py ++++ b/tests/threaded/test_thread.py +@@ -7,7 +7,7 @@ import threading + import unittest + import uuid + +-import mock ++from unittest import mock + import requests.exceptions + + from requests_toolbelt.threaded import thread +--- a/dev-requirements.txt ++++ b/dev-requirements.txt +@@ -1,4 +1,3 @@ + pytest +-mock + pyopenssl + git+git://github.com/sigmavirus24/betamax +--- a/tox.ini ++++ b/tox.ini +@@ -6,7 +6,6 @@ pip_pre = False + deps = + requests{env:REQUESTS_VERSION:>=2.0.1,<3.0.0} + pytest +- mock + pyopenssl + ndg-httpsclient + betamax>0.5.0 +--- a/tests/test_source_adapter.py ++++ b/tests/test_source_adapter.py +@@ -1,6 +1,6 @@ + # -*- coding: utf-8 -*- + from requests.adapters import DEFAULT_POOLSIZE, DEFAULT_POOLBLOCK +-from mock import patch ++from unittest.mock import patch + from requests_toolbelt.adapters.source import SourceAddressAdapter + + import pytest +--- a/tests/test_user_agent.py ++++ b/tests/test_user_agent.py +@@ -2,7 +2,7 @@ + import unittest + import sys + +-from mock import patch ++from unittest.mock import patch + import pytest + + from requests_toolbelt.utils import user_agent as ua From da9a8dcc93f9f09a9eb769d41ade4314023379b65e8e5339d8843bdee2c06393 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 14 Dec 2020 00:11:10 +0000 Subject: [PATCH 2/3] Accepting request 855621 from home:mcepl:branches:devel:tools:scm - We don't need to break Python 2.7 OBS-URL: https://build.opensuse.org/request/show/855621 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-requests-toolbelt?expand=0&rev=17 --- python-requests-toolbelt.changes | 5 ++ python-requests-toolbelt.spec | 6 ++- remove_mock.patch | 91 +++++++++++++++++++++++--------- 3 files changed, 75 insertions(+), 27 deletions(-) diff --git a/python-requests-toolbelt.changes b/python-requests-toolbelt.changes index 7856328..5312857 100644 --- a/python-requests-toolbelt.changes +++ b/python-requests-toolbelt.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sun Dec 13 21:51:50 UTC 2020 - Matej Cepl + +- We don't need to break Python 2.7 + ------------------------------------------------------------------- Mon Dec 7 08:09:35 UTC 2020 - Matej Cepl diff --git a/python-requests-toolbelt.spec b/python-requests-toolbelt.spec index 81f52e2..0d049f4 100644 --- a/python-requests-toolbelt.spec +++ b/python-requests-toolbelt.spec @@ -37,8 +37,12 @@ Requires: python-requests >= 2.12.2 BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module betamax >= 0.5.0} -BuildRequires: %{python_module pyOpenSSL} +# gh#pyca/cryptography#5606 +BuildRequires: %{python_module pyOpenSSL >= 19.1.0} BuildRequires: %{python_module pytest} +%ifpython2 +BuildRequires: %{python_module mock} +%endif # /SECTION %python_subpackages diff --git a/remove_mock.patch b/remove_mock.patch index 138c661..5c3bf86 100644 --- a/remove_mock.patch +++ b/remove_mock.patch @@ -16,119 +16,152 @@ --- a/tests/test_appengine_adapter.py +++ b/tests/test_appengine_adapter.py -@@ -2,7 +2,7 @@ +@@ -2,7 +2,10 @@ """Tests for the AppEngineAdapter.""" import sys -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest import requests --- a/tests/test_auth.py +++ b/tests/test_auth.py -@@ -1,7 +1,7 @@ +@@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- import requests import unittest -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock from requests_toolbelt.auth.guess import GuessAuth, GuessProxyAuth from . import get_betamax --- a/tests/test_downloadutils.py +++ b/tests/test_downloadutils.py -@@ -8,7 +8,7 @@ import tempfile +@@ -8,7 +8,10 @@ import tempfile import requests from requests_toolbelt.downloadutils import stream from requests_toolbelt.downloadutils import tee -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from . import get_betamax --- a/tests/test_dump.py +++ b/tests/test_dump.py -@@ -12,7 +12,7 @@ very complex and high-level. +@@ -12,7 +12,10 @@ very complex and high-level. from requests_toolbelt._compat import HTTPHeaderDict from requests_toolbelt.utils import dump -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest import requests --- a/tests/test_multipart_decoder.py +++ b/tests/test_multipart_decoder.py -@@ -2,7 +2,7 @@ +@@ -2,7 +2,10 @@ import io import sys import unittest -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest import requests from requests_toolbelt.multipart.decoder import BodyPart --- a/tests/test_proxy_digest_auth.py +++ b/tests/test_proxy_digest_auth.py -@@ -2,7 +2,7 @@ +@@ -2,7 +2,10 @@ """Test proxy digest authentication.""" import unittest -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import requests from requests_toolbelt.auth import http_proxy_digest --- a/tests/test_socket_options_adapter.py +++ b/tests/test_socket_options_adapter.py -@@ -3,7 +3,7 @@ +@@ -3,7 +3,10 @@ import contextlib import socket -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import requests from requests_toolbelt._compat import poolmanager --- a/tests/test_ssladapter.py +++ b/tests/test_ssladapter.py -@@ -1,5 +1,5 @@ +@@ -1,5 +1,8 @@ # -*- coding: utf-8 -*- -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest import requests import unittest --- a/tests/threaded/test_api.py +++ b/tests/threaded/test_api.py -@@ -1,6 +1,6 @@ +@@ -1,6 +1,9 @@ """Module containing tests for requests_toolbelt.threaded API.""" -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from requests_toolbelt._compat import queue --- a/tests/threaded/test_pool.py +++ b/tests/threaded/test_pool.py -@@ -5,7 +5,7 @@ except ImportError: +@@ -5,7 +5,10 @@ except ImportError: import Queue as queue import unittest -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import pytest from requests_toolbelt.threaded import pool --- a/tests/threaded/test_thread.py +++ b/tests/threaded/test_thread.py -@@ -7,7 +7,7 @@ import threading +@@ -7,7 +7,10 @@ import threading import unittest import uuid -import mock -+from unittest import mock ++try: ++ import unittest.mock as mock ++except ImportError: ++ import mock import requests.exceptions from requests_toolbelt.threaded import thread @@ -151,22 +184,28 @@ betamax>0.5.0 --- a/tests/test_source_adapter.py +++ b/tests/test_source_adapter.py -@@ -1,6 +1,6 @@ +@@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- from requests.adapters import DEFAULT_POOLSIZE, DEFAULT_POOLBLOCK -from mock import patch -+from unittest.mock import patch ++try: ++ from unittest.mock import patch ++except ImportError: ++ from mock import patch from requests_toolbelt.adapters.source import SourceAddressAdapter import pytest --- a/tests/test_user_agent.py +++ b/tests/test_user_agent.py -@@ -2,7 +2,7 @@ +@@ -2,7 +2,10 @@ import unittest import sys -from mock import patch -+from unittest.mock import patch ++try: ++ from unittest.mock import patch ++except ImportError: ++ from mock import patch import pytest from requests_toolbelt.utils import user_agent as ua From 7170e3f32eca7aae4f9ad600b37a91511361bc3da5a06eaea2ebddb56f7396c8 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 14 Dec 2020 06:25:59 +0000 Subject: [PATCH 3/3] Accepting request 855631 from home:bnavigator:branches:devel:languages:python - Fix condition around BuildRequirement OBS-URL: https://build.opensuse.org/request/show/855631 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-requests-toolbelt?expand=0&rev=18 --- python-requests-toolbelt.changes | 5 +++++ python-requests-toolbelt.spec | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/python-requests-toolbelt.changes b/python-requests-toolbelt.changes index 5312857..1d20ef5 100644 --- a/python-requests-toolbelt.changes +++ b/python-requests-toolbelt.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Dec 14 00:35:01 UTC 2020 - Benjamin Greiner + +- Fix condition around BuildRequirement + ------------------------------------------------------------------- Sun Dec 13 21:51:50 UTC 2020 - Matej Cepl diff --git a/python-requests-toolbelt.spec b/python-requests-toolbelt.spec index 0d049f4..568be55 100644 --- a/python-requests-toolbelt.spec +++ b/python-requests-toolbelt.spec @@ -40,8 +40,8 @@ BuildRequires: %{python_module betamax >= 0.5.0} # gh#pyca/cryptography#5606 BuildRequires: %{python_module pyOpenSSL >= 19.1.0} BuildRequires: %{python_module pytest} -%ifpython2 -BuildRequires: %{python_module mock} +%if 0%{suse_version} <= 1500 +BuildRequires: python-mock %endif # /SECTION %python_subpackages