[packages/python-httplib2] - added mock patch (prefer unittest.mock from stdlib on python3) - added tests and doc, updated depe

qboosh qboosh at pld-linux.org
Thu Apr 2 19:22:41 CEST 2020


commit ebcdddb241d41892b2fb38f7d75bd1c6d360d00b
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Thu Apr 2 19:22:36 2020 +0200

    - added mock patch (prefer unittest.mock from stdlib on python3)
    - added tests and doc, updated dependencies

 python-httplib2-mock.patch | 76 ++++++++++++++++++++++++++++++++++++++++++++++
 python-httplib2.spec       | 75 ++++++++++++++++++++++++++++++++++++---------
 2 files changed, 137 insertions(+), 14 deletions(-)
---
diff --git a/python-httplib2.spec b/python-httplib2.spec
index 238e83b..a5dfbc5 100644
--- a/python-httplib2.spec
+++ b/python-httplib2.spec
@@ -1,6 +1,9 @@
 #
 # Conditional build:
+%bcond_without	python2 # Python 2.x module
 %bcond_without	python3 # Python 3.x module
+%bcond_without	doc	# Sphinx documentation
+%bcond_without	tests	# unit tests
 
 Summary:	A comprehensive HTTP client library
 Summary(pl.UTF-8):	Obszerna biblioteka klienta HTTP
@@ -9,21 +12,41 @@ Version:	0.17.0
 Release:	1
 License:	MIT
 Group:		Development/Languages/Python
+#Source0Download: https://github.com/httplib2/httplib2/releases
+# TODO:		https://github.com/httplib2/httplib2/archive/v%{version}/httplib2-%{version}.tar.gz
 Source0:	https://github.com/httplib2/httplib2/archive/v%{version}.tar.gz
 # Source0-md5:	fbd0b80a32a4cbb1c3c459294e3a1065
 Patch0:		%{name}.certfile.patch
 Patch1:		%{name}-0.9-proxy-http.patch
+Patch2:		%{name}-mock.patch
 URL:		https://github.com/httplib2/httplib2
-BuildRequires:	python >= 2.3
-BuildRequires:	python-modules
-BuildRequires:	rpmbuild(macros) >= 1.710
-BuildRequires:	sed >= 4.0
+%if %{with python2}
+BuildRequires:	python-modules >= 1:2.7
+BuildRequires:	python-setuptools
+%if %{with tests}
+BuildRequires:	python-future >= 0.16.0
+BuildRequires:	python-mock >= 2.0.0
+BuildRequires:	python-pytest >= 3.2.1
+BuildRequires:	python-pytest-cov >= 2.5.1
+BuildRequires:	python-pytest-timeout >= 1.2.0
+BuildRequires:	python-six >= 1.10.0
+%endif
+%endif
 %if %{with python3}
-BuildRequires:	python3-devel
-BuildRequires:	python3-distribute
-BuildRequires:	python3-modules
+BuildRequires:	python3-modules >= 1:3.4
+BuildRequires:	python3-setuptools
+%if %{with tests}
+BuildRequires:	python3-pytest >= 3.2.1
+BuildRequires:	python3-pytest-cov >= 2.5.1
+BuildRequires:	python3-pytest-timeout >= 1.2.0
+BuildRequires:	python3-six >= 1.10.0
+%endif
 %endif
 BuildRequires:	rpm-pythonprov
+BuildRequires:	rpmbuild(macros) >= 1.710
+%if %{with doc}
+BuildRequires:	sphinx-pdg
+%endif
 Requires:	ca-certificates
 BuildArch:	noarch
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -58,6 +81,7 @@ cech pomijanych przez inne biblioteki. Obsługuje:
 Summary:	A comprehensive HTTP client library
 Summary(pl.UTF-8):	Obszerna biblioteka klienta HTTP
 Group:		Development/Languages/Python
+Requires:	ca-certificates
 
 %description -n python3-httplib2
 A comprehensive HTTP client library, httplib2.py supports many
@@ -89,40 +113,63 @@ cech pomijanych przez inne biblioteki. Obsługuje:
 %setup -q -n httplib2-%{version}
 %patch0 -p1
 %patch1 -p1
+%patch2 -p1
 
 %build
+%if %{with python2}
 %py_build
 
+%if %{with tests}
+PYTHONPATH=$(pwd)/build-2/lib \
+%{__python} -m pytest tests -k 'not test_certs_file_from_builtin and not test_certs_file_from_environment and not test_with_certifi_removed_from_modules and not test_noproxy_star'
+%endif
+%endif
+
 %if %{with python3}
 %py3_build
+
+%if %{with tests}
+# in python3 implementation system socks module is preferred over httplib2.socks, and the first is incompatible with test_socks5_auth
+PYTHONPATH=$(pwd)/build-3/lib \
+%{__python3} -m pytest tests -k 'not test_certs_file_from_builtin and not test_certs_file_from_environment and not test_with_certifi_removed_from_modules and not test_noproxy_star and not test_server_not_found_error_is_raised_for_invalid_hostname and not test_socks5_auth'
+%endif
+%endif
+
+%if %{with doc}
+%{__make} -C doc html
 %endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
+
+%if %{with python2}
 %py_install
-rm $RPM_BUILD_ROOT%{py_sitescriptdir}/httplib2/cacerts.txt
+
+%py_postclean
+%{__rm} $RPM_BUILD_ROOT%{py_sitescriptdir}/httplib2/cacerts.txt
+%endif
 
 %if %{with python3}
 %py3_install
-rm $RPM_BUILD_ROOT%{py3_sitescriptdir}/httplib2/cacerts.txt
-%endif
 
-%py_ocomp $RPM_BUILD_ROOT%{py_sitescriptdir}
-%py_postclean
+%{__rm} $RPM_BUILD_ROOT%{py3_sitescriptdir}/httplib2/cacerts.txt
+%endif
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
+%if %{with python2}
 %files
 %defattr(644,root,root,755)
-%doc README.md CHANGELOG
+%doc CHANGELOG LICENSE README.md
 %{py_sitescriptdir}/httplib2
 %{py_sitescriptdir}/httplib2-%{version}-py*.egg-info
+%endif
 
 %if %{with python3}
 %files -n python3-httplib2
 %defattr(644,root,root,755)
-%doc python3/README CHANGELOG
+%doc CHANGELOG LICENSE README.md python3/README
 %{py3_sitescriptdir}/httplib2
 %{py3_sitescriptdir}/httplib2-%{version}-py*.egg-info
 %endif
diff --git a/python-httplib2-mock.patch b/python-httplib2-mock.patch
new file mode 100644
index 0000000..09cd57b
--- /dev/null
+++ b/python-httplib2-mock.patch
@@ -0,0 +1,76 @@
+--- httplib2-0.17.0/tests/test_cacerts_from_env.py.orig	2020-01-24 14:57:26.000000000 +0100
++++ httplib2-0.17.0/tests/test_cacerts_from_env.py	2020-03-23 20:44:34.443627324 +0100
+@@ -1,10 +1,12 @@
+ import os
+ import sys
+-import mock
+ import pytest
+ import tempfile
+ import httplib2
+-
++try:
++    import mock
++except ImportError:
++    from unittest import mock
+ 
+ CA_CERTS_BUILTIN = os.path.join(os.path.dirname(httplib2.__file__), "cacerts.txt")
+ CERTIFI_CERTS_FILE = "unittest_certifi_file"
+--- httplib2-0.17.0/tests/test_http.py.orig	2020-01-24 14:57:26.000000000 +0100
++++ httplib2-0.17.0/tests/test_http.py	2020-03-23 20:45:02.520141887 +0100
+@@ -5,13 +5,15 @@
+ import email.utils
+ import errno
+ import httplib2
+-import mock
+ import os
+ import pytest
+ from six.moves import http_client, urllib
+ import socket
+ import tests
+-
++try:
++    import mock
++except ImportError:
++    from unittest import mock
+ 
+ def _raise_connection_refused_exception(*args, **kwargs):
+     raise socket.error(errno.ECONNREFUSED, "Connection refused.")
+--- httplib2-0.17.0/tests/test_other.py.orig	2020-01-24 14:57:26.000000000 +0100
++++ httplib2-0.17.0/tests/test_other.py	2020-03-23 20:45:22.020036247 +0100
+@@ -1,5 +1,4 @@
+ import httplib2
+-import mock
+ import os
+ import pickle
+ import pytest
+@@ -8,7 +7,10 @@
+ import tests
+ import time
+ from six.moves import urllib
+-
++try:
++    import mock
++except ImportError:
++    from unittest import mock
+ 
+ @pytest.mark.skipif(
+     sys.version_info <= (3,),
+--- httplib2-0.17.0/tests/test_proxy.py.orig	2020-01-24 14:57:26.000000000 +0100
++++ httplib2-0.17.0/tests/test_proxy.py	2020-03-23 20:45:42.219926815 +0100
+@@ -9,12 +9,15 @@
+ from __future__ import print_function
+ 
+ import httplib2
+-import mock
+ import os
+ import pytest
+ import socket
+ import tests
+ from six.moves import urllib
++try:
++    import mock
++except ImportError:
++    from unittest import mock
+ 
+ 
+ def _raise_name_not_known_error(*args, **kwargs):
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-httplib2.git/commitdiff/ebcdddb241d41892b2fb38f7d75bd1c6d360d00b



More information about the pld-cvs-commit mailing list