diff --git a/osbs-client-skip-tests.patch b/osbs-client-skip-tests.patch new file mode 100644 index 0000000..390adc0 --- /dev/null +++ b/osbs-client-skip-tests.patch @@ -0,0 +1,49 @@ +From 07e0ac510cce0ae922667a1d265c85460168bc87 Mon Sep 17 00:00:00 2001 +From: Jiri Popelka +Date: Thu, 5 Nov 2015 17:50:45 +0100 +Subject: [PATCH] Skip tests that require internet if there's no connection. + +--- + tests/test_http.py | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/tests/test_http.py b/tests/test_http.py +index c6b18ea..674f9eb 100644 +--- a/tests/test_http.py ++++ b/tests/test_http.py +@@ -13,6 +13,7 @@ import pytest + + import osbs.http as osbs_http + from osbs.http import parse_headers, HttpSession, HttpStream ++from osbs.exceptions import OsbsNetworkException + + from tests.fake_api import Connection, ResponseMapping + +@@ -24,6 +25,15 @@ def s(): + return HttpSession(verbose=True) + + ++def has_connection(): ++ # In case we run tests in an environment without internet connection. ++ try: ++ HttpStream("https://httpbin.org/get", "get") ++ return True ++ except OsbsNetworkException: ++ return False ++ ++ + class TestParseHeaders(object): + def test_parse_headers(self): + conn = Connection("0.5.4") +@@ -40,6 +50,8 @@ class TestParseHeaders(object): + assert headers["location"] + + ++@pytest.mark.skipif(not has_connection(), ++ reason="requires internet connection") + class TestHttpSession(object): + def test_single_multi_secure_without_redirs(self, s): + response_single = s.get("https://httpbin.org/get") +-- +2.5.0 + diff --git a/osbs-client.spec b/osbs-client.spec index ecc26e3..f5223d9 100644 --- a/osbs-client.spec +++ b/osbs-client.spec @@ -1,10 +1,24 @@ -%global with_python3 0 +%if 0%{?rhel} && 0%{?rhel} <= 6 +%{!?__python2: %global __python2 /usr/bin/python2} +%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} +%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")} +%{!?python2_version: %global python2_version %(%{__python2} -c "import sys; sys.stdout.write(sys.version[:3])")} +%endif + +%if (0%{?fedora} >= 22 || 0%{?rhel} >= 8) +%global with_python3 1 +%endif + +%if 0%{?fedora} +# rhel/epel has no flexmock, pytest-capturelog +%global with_check 1 +%endif %global commit 49ef2c5d631b8a0c5f82a1d9354e6f7271ba5f12 %global shortcommit %(c=%{commit}; echo ${c:0:7}) # set to 0 to create a normal release %global postrelease 0 -%global release 1 +%global release 2 %global osbs_obsolete_vr 0.14-2 @@ -22,17 +36,36 @@ License: BSD URL: https://github.com/projectatomic/osbs-client Source0: https://github.com/projectatomic/osbs-client/archive/%{commit}/osbs-client-%{commit}.tar.gz +Patch0: osbs-client-skip-tests.patch + BuildArch: noarch Requires: python-osbs-client = %{version}-%{release} BuildRequires: python2-devel BuildRequires: python-setuptools +%if 0%{?with_check} +BuildRequires: pytest +BuildRequires: python-pytest-capturelog +BuildRequires: python-flexmock +BuildRequires: python-six +BuildRequires: python-dockerfile-parse +BuildRequires: python-pycurl +%endif # with_check %if 0%{?with_python3} BuildRequires: python3-devel BuildRequires: python3-setuptools -%endif +%if 0%{?with_check} +BuildRequires: python3-pytest +BuildRequires: python3-pytest-capturelog +BuildRequires: python3-flexmock +BuildRequires: python3-six +BuildRequires: python3-dockerfile-parse +BuildRequires: python3-pycurl +%endif # with_check +%endif # with_python3 + Provides: osbs = %{version}-%{release} Obsoletes: osbs < %{osbs_obsolete_vr} @@ -50,7 +83,10 @@ Requires: python-dockerfile-parse Requires: python-pycurl Requires: python-setuptools Requires: krb5-workstation -#Requires: python-requests + +%if 0%{?rhel} && 0%{?rhel} <= 6 +Requires: python-argparse +%endif Provides: python-osbs = %{version}-%{release} Obsoletes: python-osbs < %{osbs_obsolete_vr} @@ -70,7 +106,6 @@ Requires: python3-pycurl Requires: python3-dateutil Requires: python3-setuptools Requires: krb5-workstation -#Requires: python3-requests Provides: python3-osbs = %{version}-%{release} Obsoletes: python3-osbs < %{osbs_obsolete_vr} @@ -85,6 +120,8 @@ This package contains osbs Python 3 bindings. %prep %setup -qn %{name}-%{commit} +%patch0 -p1 + %if 0%{?with_python3} rm -rf %{py3dir} cp -a . %{py3dir} @@ -116,6 +153,16 @@ mv %{buildroot}%{_bindir}/osbs %{buildroot}%{_bindir}/osbs2 ln -s %{_bindir}/osbs2 %{buildroot}%{_bindir}/osbs +%if 0%{?with_check} +%check +%if 0%{?with_python3} +LANG=en_US.utf8 py.test-%{python3_version} -vv tests +%endif # with_python3 + +LANG=en_US.utf8 py.test-%{python2_version} -vv tests +%endif # with_check + + %files %doc README.md %{_bindir}/osbs @@ -126,11 +173,7 @@ ln -s %{_bindir}/osbs2 %{buildroot}%{_bindir}/osbs %{!?_licensedir:%global license %%doc} %license LICENSE %{_bindir}/osbs2 -%if 0%{?rhel} -%{python_sitelib}/osbs* -%else %{python2_sitelib}/osbs* -%endif %dir %{_datadir}/osbs %{_datadir}/osbs/*.json @@ -147,6 +190,10 @@ ln -s %{_bindir}/osbs2 %{buildroot}%{_bindir}/osbs %endif # with_python3 %changelog +* Thu Nov 05 2015 Jiri Popelka - 0.15-2 +- build for Python 3 +- %%check section + * Mon Oct 19 2015 Tomas Tomecek - 0.15-1 - new upstream release: 0.15