Fix python2/python3 mishmash, run tests

Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1830222
This commit is contained in:
Miro Hrončok 2020-05-04 17:18:27 +02:00
parent 6463ecb14c
commit 7b346df64f
3 changed files with 94 additions and 14 deletions

View File

@ -1,7 +1,8 @@
diff -Nur httplib2-0.13.0.orig/python2/httplib2/certs.py httplib2-0.13.0/python2/httplib2/certs.py
--- httplib2-0.13.0.orig/python2/httplib2/certs.py 2019-06-06 12:46:32.000000000 -0700
+++ httplib2-0.13.0/python2/httplib2/certs.py 2019-06-30 14:29:14.050085981 -0700
@@ -23,6 +23,7 @@
diff --git a/python2/httplib2/certs.py b/python2/httplib2/certs.py
index 59d1ffc..a2e7513 100644
--- a/python2/httplib2/certs.py
+++ b/python2/httplib2/certs.py
@@ -23,6 +23,7 @@ BUILTIN_CA_CERTS = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "cacerts.txt"
)
@ -9,7 +10,7 @@ diff -Nur httplib2-0.13.0.orig/python2/httplib2/certs.py httplib2-0.13.0/python2
def where():
env = os.environ.get("HTTPLIB2_CA_CERTS")
@@ -35,7 +36,7 @@
@@ -35,7 +36,7 @@ def where():
return custom_ca_locater_where()
if certifi_available:
return certifi_where()
@ -18,10 +19,11 @@ diff -Nur httplib2-0.13.0.orig/python2/httplib2/certs.py httplib2-0.13.0/python2
if __name__ == "__main__":
diff -Nur httplib2-0.13.0.orig/python3/httplib2/certs.py httplib2-0.13.0/python3/httplib2/certs.py
--- httplib2-0.13.0.orig/python3/httplib2/certs.py 2019-06-06 12:46:32.000000000 -0700
+++ httplib2-0.13.0/python3/httplib2/certs.py 2019-06-30 14:29:38.778214191 -0700
@@ -23,6 +23,8 @@
diff --git a/python3/httplib2/certs.py b/python3/httplib2/certs.py
index 59d1ffc..2708393 100644
--- a/python3/httplib2/certs.py
+++ b/python3/httplib2/certs.py
@@ -23,6 +23,8 @@ BUILTIN_CA_CERTS = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "cacerts.txt"
)
@ -30,7 +32,7 @@ diff -Nur httplib2-0.13.0.orig/python3/httplib2/certs.py httplib2-0.13.0/python3
def where():
env = os.environ.get("HTTPLIB2_CA_CERTS")
@@ -35,7 +37,7 @@
@@ -35,7 +37,7 @@ def where():
return custom_ca_locater_where()
if certifi_available:
return certifi_where()
@ -39,3 +41,39 @@ diff -Nur httplib2-0.13.0.orig/python3/httplib2/certs.py httplib2-0.13.0/python3
if __name__ == "__main__":
diff --git a/tests/test_cacerts_from_env.py b/tests/test_cacerts_from_env.py
index cb2bd9f..0fed4d5 100644
--- a/tests/test_cacerts_from_env.py
+++ b/tests/test_cacerts_from_env.py
@@ -7,6 +7,7 @@ import httplib2
CA_CERTS_BUILTIN = os.path.join(os.path.dirname(httplib2.__file__), "cacerts.txt")
+FEDORA_CA_CERTS = "/etc/pki/tls/certs/ca-bundle.crt"
CERTIFI_CERTS_FILE = "unittest_certifi_file"
CUSTOM_CA_CERTS = "unittest_custom_ca_certs"
@@ -32,7 +33,7 @@ def ca_certs_tmpfile(clean_env):
@mock.patch("httplib2.certs.certifi_available", False)
@mock.patch("httplib2.certs.custom_ca_locater_available", False)
def test_certs_file_from_builtin(clean_env):
- assert httplib2.certs.where() == CA_CERTS_BUILTIN
+ assert httplib2.certs.where() == FEDORA_CA_CERTS
@mock.patch("httplib2.certs.certifi_available", False)
@@ -44,7 +45,7 @@ def test_certs_file_from_environment(ca_certs_tmpfile):
with pytest.raises(RuntimeError):
httplib2.certs.where()
os.environ.pop("HTTPLIB2_CA_CERTS")
- assert httplib2.certs.where() == CA_CERTS_BUILTIN
+ assert httplib2.certs.where() == FEDORA_CA_CERTS
@mock.patch("httplib2.certs.certifi_where", mock.MagicMock(return_value=CERTIFI_CERTS_FILE))
@@ -69,4 +70,4 @@ def test_with_certifi_removed_from_modules(ca_certs_tmpfile):
os.environ["HTTPLIB2_CA_CERTS"] = ca_certs_tmpfile
assert httplib2.certs.where() == ca_certs_tmpfile
os.environ.pop("HTTPLIB2_CA_CERTS")
- assert httplib2.certs.where() == CA_CERTS_BUILTIN
+ assert httplib2.certs.where() == FEDORA_CA_CERTS

View File

@ -2,11 +2,11 @@
Name: python-%{srcname}
Version: 0.17.3
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Comprehensive HTTP client library
License: MIT
URL: https://pypi.python.org/pypi/httplib2
Source: %{pypi_source}
Source: https://github.com/httplib2/httplib2/archive/v%{version}/%{srcname}-%{version}.tar.gz
#
# Patch to use the Fedora ca certs instead of the bundled ones
#
@ -33,29 +33,71 @@ Summary: %{summary}
%{?python_provide:%python_provide python3-%{srcname}}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pytest
BuildRequires: python3-pytest-timeout
BuildRequires: python3-mock
%description -n python3-%{srcname} %{_description}
%prep
%autosetup -n %{srcname}-%{version} -p1
# The implementation is different for each major Python version
# and we need to install from separate directories
%setup -qc
pushd %{srcname}-%{version}
%autopatch -p1
# Drop coverage
sed -i '/--cov/d' setup.cfg
popd
cp -a %{srcname}-%{version} python2
mv %{srcname}-%{version} python3
rm -r python2/python3
rm -r python3/python2
%build
pushd python2
%py2_build
popd
pushd python3
%py3_build
popd
%install
pushd python2
%py2_install
popd
pushd python3
%py3_install
popd
%check
pushd python3
PYTHONPATH=%{buildroot}%{python3_sitelib} pytest
popd
%files -n python2-%{srcname}
%doc python2/README.md
%{python2_sitelib}/%{srcname}-*.egg-info/
%{python2_sitelib}/%{srcname}/
%files -n python3-%{srcname}
%doc python3/README.md
%{python3_sitelib}/%{srcname}-*.egg-info/
%{python3_sitelib}/%{srcname}/
%changelog
* Mon May 04 2020 Miro Hrončok <mhroncok@redhat.com> - 0.17.3-3
- Fix python2/python3 mishmash (#1830222)
- Run tests
* Wed Apr 22 2020 Igor Raits <ignatenkobrain@fedoraproject.org> - 0.17.3-2
- Cleanup spec

View File

@ -1 +1 @@
SHA512 (httplib2-0.17.3.tar.gz) = 1559ce1995ee2c31785c748e7312538d46a249347f5c5c9bbebda76c6f159691b9cb596353b47821f93f99af688f94d6c482d53c16bce505b9280fc995fb83d7
SHA512 (httplib2-0.17.3.tar.gz) = a1af9c9e42584c4d14cf37f8a3cac9dc2bb9e03a47711e8736db02b798791585afe9515eaf3492a643a38fb3416ee1a21324c6a2ce8227e76a2f8f8ae062cad8