Include and enable tests (now python-pytest-httpbin is packaged)

This commit is contained in:
Adam Williamson 2016-12-30 11:03:31 -08:00
parent 1a7bf1a1bd
commit dbcd0be450
4 changed files with 46 additions and 17 deletions

1
.gitignore vendored
View File

@ -31,3 +31,4 @@
/requests-2.12.2.tar.gz
/requests-2.12.3.tar.gz
/requests-2.12.4.tar.gz
/requests-2.12.4-tests.tar.gz

View File

@ -11,12 +11,18 @@
Name: python-requests
Version: 2.12.4
Release: 2%{?dist}
Release: 3%{?dist}
Summary: HTTP library, written in Python, for human beings
License: ASL 2.0
URL: https://pypi.io/project/requests
Source0: https://pypi.io/packages/source/r/requests/requests-%{version}.tar.gz
# To generate:
# git clone https://github.com/kennethreitz/requests.git
# cd requests
# git checkout v%{version}
# tar cvzf requests-%{version}-tests.tar.gz tests/
Source1: requests-2.12.4-tests.tar.gz
# Explicitly use the system certificates in ca-certificates.
# https://bugzilla.redhat.com/show_bug.cgi?id=904614
Patch0: python-requests-system-cert-bundle.patch
@ -32,6 +38,13 @@ Patch1: python-requests-remove-nested-bundling-dep.patch
# - https://github.com/kennethreitz/requests/issues/2816
Patch2: python-requests-urllib3-at-%{urllib3_unbundled_version}.patch
# Use 127.0.0.1 not localhost for socket.bind() in the Server test
# class, to fix tests in Koji's no-network environment
# This probably isn't really upstreamable, because I guess localhost
# could technically be IPv6 or something, and our no-network env is
# a pretty odd one so this is a niche requirement.
Patch3: requests-2.12.4-tests_nonet.patch
BuildArch: noarch
%description
@ -47,6 +60,12 @@ Summary: HTTP library, written in Python, for human beings
BuildRequires: python2-devel
BuildRequires: python-chardet
BuildRequires: python2-urllib3 == %{urllib3_unbundled_version}
# For tests
BuildRequires: python2-pytest
BuildRequires: python2-pytest-cov
BuildRequires: python2-pytest-httpbin
BuildRequires: python2-pytest-mock
Requires: ca-certificates
Requires: python-chardet
@ -73,6 +92,12 @@ Summary: HTTP library, written in Python, for human beings
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-chardet
BuildRequires: python%{python3_pkgversion}-urllib3 == %{urllib3_unbundled_version}
# For tests
BuildRequires: python%{python3_pkgversion}-pytest
BuildRequires: python%{python3_pkgversion}-pytest-cov
BuildRequires: python%{python3_pkgversion}-pytest-httpbin
BuildRequires: python%{python3_pkgversion}-pytest-mock
Requires: python%{python3_pkgversion}-chardet
Requires: python%{python3_pkgversion}-urllib3 == %{urllib3_unbundled_version}
Requires: python%{python3_pkgversion}-idna
@ -85,11 +110,12 @@ designed to make HTTP requests easy for developers.
%endif
%prep
%setup -q -n requests-%{version}
%setup -q -n requests-%{version} -a 1
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
# Unbundle the certificate bundle from mozilla.
rm -rf requests/cacert.pem
@ -135,25 +161,12 @@ ln -s ../../chardet %{buildroot}/%{python2_sitelib}/requests/packages/chardet
ln -s ../../urllib3 %{buildroot}/%{python2_sitelib}/requests/packages/urllib3
ln -s ../../idna %{buildroot}/%{python2_sitelib}/requests/packages/idna
## We could now run the test suite if we package python-pytest-httpbin:
## https://pypi.python.org/pypi/pytest-httpbin
## Because upstream ported to that in 2015:
## https://github.com/kennethreitz/requests/issues/2184
%check
#%%{__python} test_requests.py
#%%if 0%%{?_with_python3}
#pushd %%{py3dir}
#%%{__python3} test_requests.py
#popd
#%%endif
# At very, very least, we'll try to start python and import requests
PYTHONPATH=. %{__python} -c "import requests"
PYTHONPATH=./ py.test
%if 0%{?_with_python3}
pushd %{py3dir}
PYTHONPATH=. %{__python3} -c "import requests"
PYTHONPATH=./ py.test-%{python3_pkgversion}
popd
%endif
@ -177,6 +190,9 @@ popd
%endif
%changelog
* Fri Dec 30 2016 Adam Williamson <awilliam@redhat.com> - 2.12.4-3
- Include and enable tests (now python-pytest-httpbin is packaged)
* Wed Dec 21 2016 Kevin Fenzi <kevin@scrye.com> - 2.12.4-2
- Rebuild for Python 3.6 again.

View File

@ -0,0 +1,11 @@
--- requests-2.12.4/tests/testserver/server.py 2016-12-21 11:31:56.000000000 -0800
+++ requests-2.12.4/tests/testserver/server.py.new 2016-12-30 10:40:06.085995065 -0800
@@ -27,7 +27,7 @@
"""Dummy server using for unit testing"""
WAIT_EVENT_TIMEOUT = 5
- def __init__(self, handler=None, host='localhost', port=0, requests_to_handle=1, wait_to_close_event=None):
+ def __init__(self, handler=None, host='127.0.0.1', port=0, requests_to_handle=1, wait_to_close_event=None):
super(Server, self).__init__()
self.handler = handler or consume_socket_content

View File

@ -1 +1,2 @@
SHA512 (requests-2.12.4.tar.gz) = 100a38ad4bfe5c02c44ccfa75473da4b58416690985117750a0c2e1851e98267df740f578f6a5ad27d0a5b9de2954988f832ea1a169fffc82e8e2da15742f855
SHA512 (requests-2.12.4-tests.tar.gz) = baeaa07a61c05ea6dd3f1b26225d77e1532434b7de2cad1a22e5d71eda546a2dffd49fcaa8beccc1694eccf2c69f545290c9fc48e2f0e24dc208b7eac41c920f