diff --git a/fix-tests.patch b/fix-tests.patch new file mode 100644 index 0000000..71dbdea --- /dev/null +++ b/fix-tests.patch @@ -0,0 +1,128 @@ +From c4f918572751151eb3bfc7dfa94580b3e2867a9e Mon Sep 17 00:00:00 2001 +From: Jon Dufresne +Date: Sun, 3 Feb 2019 09:02:24 -0800 +Subject: [PATCH] Fix unhandled exceptions from threads during tests + +A queue.Queue() object was not always passed to SessionThread. In this +case, SessionThread._make_request() would raise an exception trying to +call methods on the expected object. Now, always pass a usable object to +SessionThread. + +Previously appeared as: + + Traceback (most recent call last): + File "/usr/lib64/python3.7/threading.py", line 917, in _bootstrap_inner + self.run() + File "/usr/lib64/python3.7/threading.py", line 865, in run + self._target(*self._args, **self._kwargs) + File "toolbelt/requests_toolbelt/threaded/thread.py", line 41, in _make_request + kwargs = self._jobs.get_nowait() + AttributeError: 'NoneType' object has no attribute 'get_nowait' + + Exception in thread cd08fad6-d21d-41b0-921e-737a149b12be: + Traceback (most recent call last): + File "/usr/lib64/python3.7/threading.py", line 917, in _bootstrap_inner + self.run() + File "/usr/lib64/python3.7/threading.py", line 865, in run + self._target(*self._args, **self._kwargs) + File "toolbelt/requests_toolbelt/threaded/thread.py", line 41, in _make_request + kwargs = self._jobs.get_nowait() + AttributeError: 'NoneType' object has no attribute 'get_nowait' + + Exception in thread 4fb72f0d-ba1c-4a78-97a2-4a7283ea01fe: + Traceback (most recent call last): + File "/usr/lib64/python3.7/threading.py", line 917, in _bootstrap_inner + self.run() + File "/usr/lib64/python3.7/threading.py", line 865, in run + self._target(*self._args, **self._kwargs) + File "toolbelt/requests_toolbelt/threaded/thread.py", line 41, in _make_request + kwargs = self._jobs.get_nowait() + AttributeError: 'NoneType' object has no attribute 'get_nowait' + + Exception in thread 5f3711af-0c01-4821-9e25-8074bbbf769b: + Traceback (most recent call last): + File "/usr/lib64/python3.7/threading.py", line 917, in _bootstrap_inner + self.run() + File "/usr/lib64/python3.7/threading.py", line 865, in run + self._target(*self._args, **self._kwargs) + File "toolbelt/requests_toolbelt/threaded/thread.py", line 41, in _make_request + kwargs = self._jobs.get_nowait() + AttributeError: 'NoneType' object has no attribute 'get_nowait' +--- + tests/threaded/test_pool.py | 15 ++++++++++----- + tests/threaded/test_thread.py | 5 ++++- + 2 files changed, 14 insertions(+), 6 deletions(-) + +diff --git a/tests/threaded/test_pool.py b/tests/threaded/test_pool.py +index b0653bb..b949dd8 100644 +--- a/tests/threaded/test_pool.py ++++ b/tests/threaded/test_pool.py +@@ -26,32 +26,37 @@ def test_requires_positive_number_of_processes(self): + + def test_number_of_processes_can_be_arbitrary(self): + """Show that the number of processes can be set.""" +- p = pool.Pool(None, num_processes=100) ++ job_queue = queue.Queue() ++ p = pool.Pool(job_queue, num_processes=100) + assert p._processes == 100 + assert len(p._pool) == 100 + +- p = pool.Pool(None, num_processes=1) ++ job_queue = queue.Queue() ++ p = pool.Pool(job_queue, num_processes=1) + assert p._processes == 1 + assert len(p._pool) == 1 + + def test_initializer_is_called(self): + """Ensure that the initializer function is called.""" ++ job_queue = queue.Queue() + initializer = mock.MagicMock() +- pool.Pool(None, num_processes=1, initializer=initializer) ++ pool.Pool(job_queue, num_processes=1, initializer=initializer) + assert initializer.called is True + initializer.assert_called_once_with(mock.ANY) + + def test_auth_generator_is_called(self): + """Ensure that the auth_generator function is called.""" ++ job_queue = queue.Queue() + auth_generator = mock.MagicMock() +- pool.Pool(None, num_processes=1, auth_generator=auth_generator) ++ pool.Pool(job_queue, num_processes=1, auth_generator=auth_generator) + assert auth_generator.called is True + auth_generator.assert_called_once_with(mock.ANY) + + def test_session_is_called(self): + """Ensure that the session function is called.""" ++ job_queue = queue.Queue() + session = mock.MagicMock() +- pool.Pool(None, num_processes=1, session=session) ++ pool.Pool(job_queue, num_processes=1, session=session) + assert session.called is True + session.assert_called_once_with() + +diff --git a/tests/threaded/test_thread.py b/tests/threaded/test_thread.py +index bb92f7f..fd7e96b 100644 +--- a/tests/threaded/test_thread.py ++++ b/tests/threaded/test_thread.py +@@ -19,6 +19,8 @@ def _make_mocks(): + + def _initialize_a_session_thread(session=None, job_queue=None, + response_queue=None, exception_queue=None): ++ if job_queue is None: ++ job_queue = queue.Queue() + with mock.patch.object(threading, 'Thread') as Thread: + thread_instance = mock.MagicMock() + Thread.return_value = thread_instance +@@ -52,10 +54,11 @@ def test_thread_initialization(self): + + def test_is_alive_proxies_to_worker(self): + """Test that we proxy the is_alive method to the Thread.""" ++ job_queue = queue.Queue() + with mock.patch.object(threading, 'Thread') as Thread: + thread_instance = mock.MagicMock() + Thread.return_value = thread_instance +- st = thread.SessionThread(None, None, None, None) ++ st = thread.SessionThread(None, job_queue, None, None) + + st.is_alive() + thread_instance.is_alive.assert_called_once_with() diff --git a/python-requests-toolbelt.changes b/python-requests-toolbelt.changes index 9169cba..c36ca95 100644 --- a/python-requests-toolbelt.changes +++ b/python-requests-toolbelt.changes @@ -1,3 +1,33 @@ +------------------------------------------------------------------- +Mon May 6 14:06:37 UTC 2019 - Tomáš Chvátal + +- Add patch to fix tests fix-tests.patch +- Use pytest to execute the tests, same as the upstream + +------------------------------------------------------------------- +Thu Apr 25 19:57:47 UTC 2019 - Dirk Mueller + +- update to 0.9.1: + - Fix import of pyOpenSSL shim from urllib3 for PKCS12 adapter + - Add X509 Adapter that can handle PKCS12 + - Add stateless solution for streaming files by MultipartEncoder from one host to another (in chunks) + - Update link to example + - Move import of ``ABCs`` from collections into version-specific part of + _compat module + - Fix backwards incompatibility in ``get_encodings_from_content`` + - Correct callback documentation for ``MultipartEncoderMonitor`` + - Fix bug when ``MultipartEncoder`` is asked to encode zero parts + - Correct the type of non string request body dumps + - Removed content from being stored in MultipartDecoder + - Fix bug by enabling support for contenttype with capital letters. + - Coerce proxy URL to bytes before dumping request + - Avoid bailing out with exception upon empty response reason + - Corrected Pool documentation + - Corrected parentheses match in example usage + - Fix "oject" to "object" in ``MultipartEncoder`` + - Fix URL for the project after the move + - Add fix for OSX TCPKeepAliveAdapter + ------------------------------------------------------------------- Fri Jun 30 16:59:55 UTC 2017 - aloisio@gmx.com diff --git a/python-requests-toolbelt.spec b/python-requests-toolbelt.spec index fe38d38..8dcc495 100644 --- a/python-requests-toolbelt.spec +++ b/python-requests-toolbelt.spec @@ -1,7 +1,7 @@ # # spec file for package python-requests-toolbelt # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,31 +12,32 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-requests-toolbelt -Version: 0.8.0 +Version: 0.9.1 Release: 0 Summary: A utility belt for advanced users of python3-requests License: Apache-2.0 Group: Development/Languages/Python -Url: https://toolbelt.readthedocs.org +URL: https://github.com/requests/toolbelt Source: https://files.pythonhosted.org/packages/source/r/requests-toolbelt/requests-toolbelt-%{version}.tar.gz -BuildRequires: %{python_module requests >= 2.0.1} +Patch0: fix-tests.patch +BuildRequires: %{python_module requests >= 2.12.2} BuildRequires: %{python_module setuptools} -# SECTION test requirements -BuildRequires: %{python_module betamax} -BuildRequires: %{python_module mock} -BuildRequires: %{python_module pytest} -# /SECTION BuildRequires: fdupes BuildRequires: python-rpm-macros -Requires: python-requests >= 2.0.1 -BuildRoot: %{_tmppath}/%{name}-%{version}-build +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 %python_subpackages %description @@ -47,21 +48,24 @@ some idiosyncracies prevent effective or sane testing on that version. %prep %setup -q -n requests-toolbelt-%{version} +%patch0 -p1 rm -rf requests_toolbelt.egg-info +# requires network access +rm -v tests/test_multipart_encoder.py %build %python_build %install %python_install -%python_expand %fdupes -s %{buildroot}%{$python_sitelib} +%python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%python_exec setup.py test +%pytest %files %{python_files} -%defattr(-,root,root,-) -%doc AUTHORS.rst HISTORY.rst LICENSE README.rst +%license LICENSE +%doc README.rst %{python_sitelib}/* %changelog diff --git a/requests-toolbelt-0.8.0.tar.gz b/requests-toolbelt-0.8.0.tar.gz deleted file mode 100644 index 8233d7c..0000000 --- a/requests-toolbelt-0.8.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f6a531936c6fa4c6cfce1b9c10d5c4f498d16528d2a54a22ca00011205a187b5 -size 196129 diff --git a/requests-toolbelt-0.9.1.tar.gz b/requests-toolbelt-0.9.1.tar.gz new file mode 100644 index 0000000..d5e9d2d --- /dev/null +++ b/requests-toolbelt-0.9.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0 +size 207286